Skip to content

Latest commit

 

History

History
77 lines (62 loc) · 10.5 KB

CLEOS-GUIDE.md

File metadata and controls

77 lines (62 loc) · 10.5 KB

cleos

Note that all these actions provide already RLP encoded TXs, thus they must be done in order (due to nonce)

CONSTANTS (Change as needed)

export EVM_CONTRACT="evmcontract2"
export EOSIO_ACCOUNT="evmaccount11"
export ENDPOINT="https://jungle.eosdac.io"
export CONTRACT_DIR="/Users/jafri/eosio.evm/eosio.evm"

Deploying Contract

cleos -u $ENDPOINT set contract $EVM_CONTRACT $CONTRACT_DIR

Set eosio.code permission

cleos -u $ENDPOINT set account permission $EVM_CONTRACT active --add-code

Clear all data (Testing Only)

cleos -u $ENDPOINT push action $EVM_CONTRACT clearall "[]" -p $EVM_CONTRACT@active

Creates new address based on RLP(eosaccount, arbitrary)

cleos -u $ENDPOINT push action $EVM_CONTRACT create '["evmaccount11", "test"]' -p $EOSIO_ACCOUNT@active

Query new address

cleos -u $ENDPOINT get table $EVM_CONTRACT $EVM_CONTRACT account

Transfer token to contract to deposit to address

cleos -u $ENDPOINT transfer $EOSIO_ACCOUNT $EVM_CONTRACT "0.0002 EOS" "Deposit"

Query again to confirm balance change

cleos -u $ENDPOINT get table $EVM_CONTRACT $EVM_CONTRACT account

Deploy ERC20 FIRE Token (pass in raw TX and sender parameters)

cleos -u $ENDPOINT push action $EVM_CONTRACT raw '["f90f6e0101831e84808080b90f6060806040523480156200001157600080fd5b5060405162000e6038038062000e60833981810160405260808110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82516401000000008111828201881017156200008957600080fd5b82525081516020918201929091019080838360005b83811015620000b85781810151838201526020016200009e565b50505050905090810190601f168015620000e65780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010a57600080fd5b9083019060208201858111156200012057600080fd5b82516401000000008111828201881017156200013b57600080fd5b82525081516020918201929091019080838360005b838110156200016a57818101518382015260200162000150565b50505050905090810190601f168015620001985780820380516001836020036101000a031916815260200191505b506040908152602082810151929091015186519294509250859185918591620001c891600391908601906200038b565b508151620001de9060049060208501906200038b565b506005805460ff191660ff929092169190911790555062000202905033826200020c565b5050505062000430565b6001600160a01b03821662000268576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6200027f600083836001600160e01b036200032416565b6200029b816002546200032960201b620008831790919060201c565b6002556001600160a01b03821660009081526020818152604090912054620002ce9183906200088362000329821b17901c565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b505050565b60008282018381101562000384576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620003ce57805160ff1916838001178555620003fe565b82800160010185558215620003fe579182015b82811115620003fe578251825591602001919060010190620003e1565b506200040c92915062000410565b5090565b6200042d91905b808211156200040c576000815560010162000417565b90565b610a2080620004406000396000f3fe608060405234801561001057600080fd5b50600436106100b95760003560e01c80633950935111610081578063a457c2d71161005b578063a457c2d714610243578063a9059cbb1461026f578063dd62ed3e1461029b576100b9565b806339509351146101e957806370a082311461021557806395d89b411461023b576100b9565b806306fdde03146100be578063095ea7b31461013b57806318160ddd1461017b57806323b872dd14610195578063313ce567146101cb575b600080fd5b6100c66102c9565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101005781810151838201526020016100e8565b50505050905090810190601f16801561012d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101676004803603604081101561015157600080fd5b506001600160a01b03813516906020013561035f565b604080519115158252519081900360200190f35b61018361037c565b60408051918252519081900360200190f35b610167600480360360608110156101ab57600080fd5b506001600160a01b03813581169160208101359091169060400135610382565b6101d361040f565b6040805160ff9092168252519081900360200190f35b610167600480360360408110156101ff57600080fd5b506001600160a01b038135169060200135610418565b6101836004803603602081101561022b57600080fd5b50356001600160a01b031661046c565b6100c6610487565b6101676004803603604081101561025957600080fd5b506001600160a01b0381351690602001356104e8565b6101676004803603604081101561028557600080fd5b506001600160a01b038135169060200135610556565b610183600480360360408110156102b157600080fd5b506001600160a01b038135811691602001351661056a565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103555780601f1061032a57610100808354040283529160200191610355565b820191906000526020600020905b81548152906001019060200180831161033857829003601f168201915b5050505050905090565b600061037361036c610595565b8484610599565b50600192915050565b60025490565b600061038f848484610685565b6104058461039b610595565b61040085604051806060016040528060288152602001610955602891396001600160a01b038a166000908152600160205260408120906103d9610595565b6001600160a01b03168152602081019190915260400160002054919063ffffffff6107ec16565b610599565b5060019392505050565b60055460ff1690565b6000610373610425610595565b846104008560016000610436610595565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61088316565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103555780601f1061032a57610100808354040283529160200191610355565b60006103736104f5610595565b84610400856040518060600160405280602581526020016109c6602591396001600061051f610595565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff6107ec16565b6000610373610563610595565b8484610685565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3390565b6001600160a01b0383166105de5760405162461bcd60e51b81526004018080602001828103825260248152602001806109a26024913960400191505060405180910390fd5b6001600160a01b0382166106235760405162461bcd60e51b815260040180806020018281038252602281526020018061090d6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166106ca5760405162461bcd60e51b815260040180806020018281038252602581526020018061097d6025913960400191505060405180910390fd5b6001600160a01b03821661070f5760405162461bcd60e51b81526004018080602001828103825260238152602001806108ea6023913960400191505060405180910390fd5b61071a8383836108e4565b61075d8160405180606001604052806026815260200161092f602691396001600160a01b038616600090815260208190526040902054919063ffffffff6107ec16565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610792908263ffffffff61088316565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561087b5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610840578181015183820152602001610828565b50505050905090810190601f16801561086d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156108dd576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122037440f943b5b16ad0a4cff3a265526f4d149a93b7eb4accca00537eaeeba5f8d64736f6c63430006030033000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000000a4649524520546f6b656e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044649524500000000000000000000000000000000000000000000000000000000808080", "48a300eaac76eac0957223c132c43f7a5f3f1576"]' -p $EOSIO_ACCOUNT@active

Query Contract Storage (using address index as scope) (all keys and values are 256 bit BE encoded hex)

cleos -u $ENDPOINT get table $EVM_CONTRACT 1 accountstate

Transfer 0.0001 EOS to 0xf79b834a37f3143f4a73fc3934edac67fd3a01cd inside the EVM

cleos -u $ENDPOINT push action $EVM_CONTRACT raw '["e00201831e848094f79b834a37f3143f4a73fc3934edac67fd3a01cd0180808080", "48a300eaac76eac0957223c132c43f7a5f3f1576"]' -p $EOSIO_ACCOUNT@active

Transfer 1000 FIRE tokens to 0xf79b834a37f3143f4a73fc3934edac67fd3a01cd

cleos -u $ENDPOINT push action $EVM_CONTRACT raw '["f8650301831e8480944fe73a1111231dd432811d75a70daec79b99ab4580b844a9059cbb000000000000000000000000f79b834a37f3143f4a73fc3934edac67fd3a01cd00000000000000000000000000000000000000000000000000000000000003e8808080", "48a300eaac76eac0957223c132c43f7a5f3f1576"]' -p $EOSIO_ACCOUNT@active

Query Contract Storage (using address index as scope) (all keys and values are 256 bit BE encoded hex)

cleos -u $ENDPOINT get table $EVM_CONTRACT 1 accountstate

Withdraw tokens

cleos -u $ENDPOINT push action $EVM_CONTRACT withdraw '["evmaccount11", "0.0001 EOS"]' -p $EOSIO_ACCOUNT@active

For full encoding data, decoding data, automatic nonce management and more features, check out the JS SDK