// EstimateGas makes an RPC call to get the estimated gas needed for a transaction that sends "value" to address "to". Optionally, data may be filled and it is also taken into account.
// To get gasLimit execute in a terminal:
//  curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"to":"0x1CD434711fBAe1f2d9C70001409Fd82d71fDCCAa", "value":"0xb1a2bc2ec50000", "data":"0xfffe3031"}],"id":1}' -u <user:secret> https://ropsten.infura.io/v3/projectId
EstimateGas makes an RPC call to get the estimated gas needed for a transaction that sends "value" to address "to". Optionally, data may be filled and it is also taken into account.
// EstimateGas makes an RPC call to get the estimated gas needed for a transaction that sends " value " to address " to " . Optionally data may be filled and it is also taken into account . // To get gasLimit execute in a terminal : // curl - X POST -- data ' { " jsonrpc " : " 2 . 0 " " method " : " eth_estimateGas " " params " : [ { " to " : " 0x1CD434711fBAe1f2d9C70001409Fd82d71fDCCAa " " value " : " 0xb1a2bc2ec50000 " " data " : " 0xfffe3031 " } ] " id " : 1 } ' - u <user : secret > https : // ropsten . infura . io / v3 / projectId
func (c *EthCli) EstimateGas(to, value, data string) (gas uint64, err error) {
	if len(data) == 2+68*2 && (data[2:10] == ERC20transfer || data[2:10] == ERC20transfer256) ||
		len(data) == 2+100*2 && (data[2:10] == ERC20transferFrom || data[2:10] == ERC20transferFrom256) {
		return GasTransferToken, nil
	}
	var response interface{}
	var tmp string = ""
	if len(value) > 2 {
		tmp = "0x" + strings.TrimLeft(value[2:], "0")
		if tmp == "0x" {
			tmp = ""
		}
	}
	if err = c.Call("eth_estimateGas", []interface{}{map[string]interface{}{"to": to, "value": tmp, "data": data}}, &response); err != nil {
		return
	}
	return strconv.ParseUint(response.(string), 0, 64)
}
func ( c * EthCli ) EstimateGas ( to , value , data string ) ( gas uint64 , err error ) { if len ( data ) == 2 + 68 * 2 && ( data [ 2 : 10 ] == ERC20transfer || data [ 2 : 10 ] == ERC20transfer256 ) || len ( data ) == 2 + 100 * 2 && ( data [ 2 : 10 ] == ERC20transferFrom || data [ 2 : 10 ] == ERC20transferFrom256 ) { return GasTransferToken , nil } var response interface { } var tmp string = " " if len ( value ) > 2 { tmp = " " + strings . TrimLeft ( value [ 2 : ] , " " ) if tmp == " " { tmp = " " } } if err = c . Call ( " " , [ ] interface { } { map [ string ] interface { } { " " : to , " " : tmp , " " : data } } , & response ) ; err != nil { return } return strconv . ParseUint ( response . ( string ) , 0 , 64 ) }
EstimateGas makes an RPC call to get the estimated gas needed for a transaction that sends "value" to address "to".
EstimateGas makes an RPC call to get the estimated gas needed for a transaction that sends " value " to address " to " .
// if an ERC token transfer, just return enough gas // geth nodes have problems unmarshaling values with leading zeroes (ie. 0x04fc), so we remove them. Parity does not have this problem // call the node