/sendTransactionToEvmContractWithContractInfo
1 min
POST
http://1.1.1.1/sendTransactionToEvmContractWithContractInfo
account_idintegerthe account to send from
contract_addressstringthe address of the contract to send to
amountstring<p>the amount to send with this transaction, in Wei</p>
gas_limitinteger<p>gas limit we want to transfer, in gas units - must be at least 21500</p>
gas_priceinteger<p>the gas price we want to transfer, in wei</p>
function_namestring<p>representing the function name to call, e.g. "foo" (with no params).</p>
max_priority_feestring<p>the max priority fee we want to tip the miner. Should be sent in EVM / ERC20 transactions that are EIP1559 type, otherwise should be None. (for more info, read <a href="https://metamask.io/1559/" target="_blank">https://metamask.io/1559/</a>)</p>
validate_transactionboolean<p>if this is true, the MPC wallet will access the node to check if this transaction is
likely to fail by running dry-run, and will block the transaction if it is</p>
parameters_fields_types_and_valuesobjectlist of pairs of "type" and value for each parameter in the function (see below)
e.g [["int","32432"],["bytes","0x1234567890"],["int8[3]",["-20","0","127"]],["string","got the idea, right?"]]
* @subparam type string representing the parameters types, e.g. ["int32","uint256","string[]","bool"]
GK8 system supports all the types supported by solidity:
* uint<M>: unsigned integer type of M bits, 0 < M <= 256, M % 8 == 0. e.g. uint32, uint8, uint256. (uint is uint256)
* int<M>: signed integer type of M bits, 0 < M <= 256, M % 8 == 0. e.g. int32, int8, int256. (int is int256)
* address
* bool
* bytes<M>: binary type of M bytes, 0 < M <= 32
* function: an address (20 bytes) followed by a function selector (4 bytes).
* <type>[M]: an array of constant size of any type, e.g. int[32], string[7], bytes3[2],....
* bytes: an unlimited collection of bytes
* string: string in UTF8
* <type>[]: a variable-length array of elements of the given type. e.g. int[], string[], bytes3[],....
* tuple: (T1,T2,...,Tn): tuple consisting of the types T1, …, Tn, n >= 0, e.g. (int,string,int[32])
IMPORTANT: you must spell the type name correctly! No redundant spaces, no Capitals, spelling it in a wrong way will cause the request to fail.
* @subparam value representing the value of parameters in parameters_fields_types, e.g. ["12345678","34769874356980435879",["1.2","34","-1.2"],["bl","cl","mkasdsa"],"True"]
Except than "function", "fixed length array", "variable-length array", "tuple", all the values must be given as strings, even ints.
Those 4 types are given as python lists containing in inner value in each cell. Some examples:
* uint<M>: any base 10 non negative number in range of M bits: "2131" / "12131" / "45678906543467890" / "0"
* int<M>: any base 10 number in range of two's complement M bits: "2131" / "-2131" / "45678906543467890" / "0"
* address: any EVM address, 0x + 40 hex chars "0xEDF9C138F990b4ed9b7cb83F6ad8fF76017572B9" / "0x0000C138F990B4ED9B7CB83F6AD8FF76017572B9", "0xedf9c138f990b4ed9b7cb83f6ad8ff76017572b9"
* bool: "true" / "false"
* bytes<M>: given in hex with 0x prefix, must hold 2*M hex characters "0x00F9C138F990b4ed9b7c" / "0xEDF9C138F990B4ED9B7CB83F6AD8FF76017572B9" / "0xe9"
* function: a python list of length 2, holding address and one of "4 bytes digested function pointer e.g. 0x1234abcd" or "function declaration ready to be hashed, e.g. 'foo(int,string)'"
["0xEDF9C138F990b4ed9b7cb83F6ad8fF76017572B9","0x1234abcd"] / ["0x0000C138F990B4ED9B7CB83F6AD8FF76017572B9","foo(int,string)"]
* <type>[M]: python list of <type>, e.g.
int[3] -> ["2342","-32432","1"]
bytes3[2] -> ["0x232323","0x000011","0xabABcd"]
bool[3] -> ["True","True","False"]
* bytes: same as bytes<M>, must start with 0x and hold an even non negative count of hex digits
* string: "hello world!" / "×©×œ×•× ×¢×•×œ×!" / "Ethereum is so cool :)"
* <type>[]: same as <type>[M]
* tuple: (T1,T2,...,Tn): python list of the types, e.g.
(int,string,bool[3]) -> ["-2133242","tuples are kind of redundant,right?", ["True","True","False"]]
(int,string,(int, bool[3])) -> ["7","tuples are redundant", ["7",["True","True","False"]]]
specificFromAddressstringDeposit address to send from
evm_coin_symbolstring<p>the coin symbol of the EVM network on which the smart contract is deployed, for example: ETH, CELO, etc...</p>
descriptionstring<p>free text for describing the transaction (will not be sent to the blockchain)</p>
bodyobjectRequest data for an Ethereum transaction.
200success
curl --request POST \
--url 'http://1.1.1.1/sendTransactionToEvmContractWithContractInfo?account_id=1&contract_address=0x04e5C3F98ac6711baDd357A76E8FEAe226Dd60c7&amount=6000&gas_limit=21500&gas_price=100000000000&function_name=transfer&validate_transaction=False¶meters_fields_types_and_values=%22[%5Cn%20%20[%5C%22address%5C%22%2C%20%5C%220xEDF9C138F990b4ed9b7cb83F6ad8fF76017572B9%5C%22]%2C%5Cn%20%20[%5C%22uint256%5C%22%2C%20%5C%22100000000000000000%5C%22]%5Cn]%5Cn%5Cn%5Cn%20%20%20%20%20%20%20%20%5Cn%22&specificFromAddress=0x862842A56B5D5F30B7d519cCe683983F57499cE6&evm_coin_symbol=ETH&description=transferExample' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"AccountId": 1,
"CoinType": "ETH",
"DataForContract": {
"FunctionName": "transfer",
"ParametersFieldsTypesAndValues": [
{
"ParameterType": "address",
"ParameterValue": "0xEDF9C138F990b4ed9b7cb83F6ad8fF76017572B9"
}
],
"validateTransaction": "true"
},
"Fee": {
"GasLimit": 21500,
"GasPrice": "100000000000"
},
"IsMetaMaskTransaction": "False",
"SpecificFromAddress": "0x862842A56B5D5F30B7d519cCe683983F57499cE6",
"Transactions": [
{
"AmountToTransfer": "6000",
"DestinationAddress": "0x04e5C3F98ac6711baDd357A76E8FEAe226Dd60c7"
}
],
"UserDescription": "transferExample",
"Meta": {
"FunctionName": "sendTransactionToEvmContractWithContractInfo",
"RandomData": "288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229",
"Destination": "b9cb8afe52f1d52521cf2b62dfe12146156ad5328f83c62c20c7da81b263356a61340de745c858998544c041798b01c2f4fac31bebe52a19280a32cd57d6d374ea",
"Time": "2021-02-07T18:37:46.948Z",
"Source": "048b99461a70a49abe63fd585cb224177a22a92d2e9e4ddfbc0027887bee9d1843388f42a3eb2e740565e115ad8b7981abf59e3b03b771f4b063b53c517d7a9d99",
"AccessToken": "51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087"
}
}'- This function facilitates sending a transaction to an EVM (Ethereum Virtual Machine) smart contract
- return - Dict, e.g. {"FunctionName":"transfer", "ParametersFieldsTypesAndValues":[["address","0xEDF9C138F990b4ed9b7cb83F6ad8fF76017572B9"], ["uint256","100000000000000000"]]} ** NOTE: success or failure in this api call does not necessarily means success or failure in the transaction itself. ** for example, the transaction may work by the response to the client can be lost in communication (if the internet is down for the client). ** another example is that the transaction was approved here but failed in the signing process To know the status of the transaction you can access the function getTransactionByToken. To get the token to send those functions you should call getCurrentToken one action BEFORE sendTransaction myTokenToStoreInTheDb = user.getCurrentToken() sendTransactionToEvmContractWithContractInfo(...) ..... user.getTransactionByToken(myTokenToStoreInTheDb,"ETH")
example:
- ETH: sendTransactionToEvmContractWithContractInfo(1,"0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe","6000","50000000000",70000, "transfer",[["address","0xEDF9C138F990b4ed9b7cb83F6ad8fF76017572B9"], ["uint256","100000000000000000"]],True,"false","transferExample",None,"1000000000","ETH")