// GetTokenName makes an RPC call to get a token (identified by contract address) name.
// token: address of the contract that defines the token. It must be ERC20 compliant
// Executes:
//  curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0xa34de7bd2b4270c0b12d5fd7a0c219a4d68d732f","data":"0x06fdde03"},"latest"],"id":4}' http://localhost:8545
GetTokenName makes an RPC call to get a token (identified by contract address) name.
token: address of the contract that defines the token.
// GetTokenName makes an RPC call to get a token ( identified by contract address ) name . // token : address of the contract that defines the token . It must be ERC20 compliant // Executes : // curl - X POST -- data ' { " jsonrpc " : " 2 . 0 " " method " : " eth_call " " params " : [ { " to " : " 0xa34de7bd2b4270c0b12d5fd7a0c219a4d68d732f " " data " : " 0x06fdde03 " } " latest " ] " id " : 4 } ' http : // localhost : 8545
func (c *EthCli) GetTokenName(token string) (name string, err error) {
	var response interface{}
	var result string
	var tmp []byte
	var length int64
	if token == "" {
		return "Ether", nil
	}
	if len(token) != 42 {
		return name, ErrBadToken
	}
	if err = c.Call("eth_call", []interface{}{map[string]interface{}{"to": token, "data": "0x06fdde03"}, "latest"}, &response); err != nil {
		return "", err
	}
	result = response.(string)
	if result == "0x" {
		return "", ErrNoToken
	}
	if len(result) >= 2+64*2 {
		length, err = strconv.ParseInt(result[2+64:2+64*2], 16, 64)
		if len(result) >= 2+64*2+int(length*2) {
			tmp, err = hex.DecodeString(result[2+64*2 : 2+64*2+int(length*2)])
		} else {
			err = ErrNoToken
		}
	} else {
		err = ErrNoToken
	}
	return string(tmp), err
}
func ( c * EthCli ) GetTokenName ( token string ) ( name string , err error ) { var response interface { } var result string var tmp [ ] byte var length int64 if token == " " { return " " , nil } if len ( token ) != 42 { return name , ErrBadToken } if err = c . Call ( " " , [ ] interface { } { map [ string ] interface { } { " " : token , " " : " " } , " " } , & response ) ; err != nil { return " " , err } result = response . ( string ) if result == " " { return " " , ErrNoToken } if len ( result ) >= 2 + 64 * 2 { length , err = strconv . ParseInt ( result [ 2 + 64 : 2 + 64 * 2 ] , 16 , 64 ) if len ( result ) >= 2 + 64 * 2 + int ( length * 2 ) { tmp , err = hex . DecodeString ( result [ 2 + 64 * 2 : 2 + 64 * 2 + int ( length * 2 ) ] ) } else { err = ErrNoToken } } else { err = ErrNoToken } return string ( tmp ) , err }
GetTokenName makes an RPC call to get a token (identified by contract address) name.
GetTokenName makes an RPC call to get a token ( identified by contract address ) name .