{"id":27298553,"url":"https://github.com/mojtaba-esk/evmos-smart-contract","last_synced_at":"2025-04-12T00:36:59.503Z","repository":{"id":47352337,"uuid":"510655716","full_name":"mojtaba-esk/evmos-smart-contract","owner":"mojtaba-esk","description":"This is a cli tool to deploy a smart contract to evmos chain plus a querying methods and sending transactions to a contract.","archived":false,"fork":false,"pushed_at":"2023-07-19T05:38:29.000Z","size":162,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-06-21T13:13:29.060Z","etag":null,"topics":["cli","cosmos-sdk","ethermint","evmos","smart-contracts"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mojtaba-esk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-07-05T08:45:16.000Z","updated_at":"2024-04-24T07:26:13.000Z","dependencies_parsed_at":"2023-10-11T09:12:05.159Z","dependency_job_id":null,"html_url":"https://github.com/mojtaba-esk/evmos-smart-contract","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.038461538461538436","last_synced_commit":"498db3edd2b695f2715b3d907dc76f04656ad658"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mojtaba-esk%2Fevmos-smart-contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mojtaba-esk%2Fevmos-smart-contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mojtaba-esk%2Fevmos-smart-contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mojtaba-esk%2Fevmos-smart-contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mojtaba-esk","download_url":"https://codeload.github.com/mojtaba-esk/evmos-smart-contract/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501967,"owners_count":21114681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cosmos-sdk","ethermint","evmos","smart-contracts"],"created_at":"2025-04-12T00:36:58.749Z","updated_at":"2025-04-12T00:36:59.474Z","avatar_url":"https://github.com/mojtaba-esk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Evmos Smart Contract simple cli\nThis is a cli tool to deploy a smart contract to `evmos` chain plus a querying methods and sending transactions to a contract.\n\n## Install\n```bash\ngit clone https://github.com/mojtaba-esk/evmos-smart-contract.git\ncd evmos-smart-contract\nmake install\n```\n\nto checkout if the tool is ready to use, run this command:\n```bash\nevmos-smart-contract --help\n```\nyou should see the help info:\n```bash\nDeploy and manage a smart contract on evmos\n\nUsage:\n  evmos-smart-contract [command]\n\nAvailable Commands:\n  balance     Query the balance of a contract\n  completion  Generate the autocompletion script for the specified shell\n  deploy      Deploy a contract to the evmos chain\n  help        Help about any command\n  keys        Manage your applications keys\n  query       Query a contract to the evmos chain\n  transfer    Transfer a contract tokens to an address\n  tx          Call a method of a contract that modifies the state\n\nFlags:\n      --algo string                      The algorithm used to generate the keys (default \"eth_secp256k1\")\n      --chain-id string                  The evmos chain id (default \"evmos_9000-1\")\n      --compiled-contracts-path string   The path to the compiled contracts in json format (default \"/home/moji/mojimos/evmos-smart-contract/contracts/compiled_contracts\")\n  -h, --help                             help for evmos-smart-contract\n      --keyring-backend string           Keyring backend to use, default value is: os (default \"os\")\n      --keyring-dir string               Keyring backend directory (default \"/home/moji/.evmosd\")\n      --node string                      The evmos node to connect to (default \"http://localhost:8545\")\n      --output string                    Output format (text|json) (default \"text\")\n\nUse \"evmos-smart-contract [command] --help\" for more information about a command.\n```\n\n## Running a local `evmos` node\nFirst you need to get the evmos daemon binary.\n\n```bash\ngit clone https://github.com/evmos/evmos.git\ncd evmos\nmake install\n```\nIf you face some errors make sure you have the prerequisites installed and configured properly. Checkout the [evmos repo](https://github.com/evmos/evmos/)\n\nCheck if `evmosd` is ready to use:\n```bash\nevmosd version\n```\n\nThen we go to the cli directory and initialize the local testnet\n```bash\ncd evmos-smart-contract\n./init.sh\n```\nit will create an account and fills it up with funds and starts a local evmos testnet.\n\n## Commands\n\n### List the available accounts:\n```bash\nevmos-smart-contract keys list --keyring-backend test\n```\nsince we are using a test environment, we use `--keyring-backend test` in all commands.\n\n### Deploy a smart contract\n\nThe simplest way to deploy a smart contract is to put the solidity files inside `contracts` directory and run the following commands.\n\nFirst we make sure we have all the required tools installed on our machine by running this command:\n\n```sh\nmake contract-tools\n```\nAfter having the contract tools installed, let's compile all the contracts:\n\n```bash\nmake contracts-compile\n```\n\nNow we can deploy the smart contract that we want. Here is the usage:\n```sh\nevmos-smart-contract deploy [contract_name] [init_params_json] [flags]\n```\n\nLet's deploy the `HelloWorld` contract:\n\n```sh\nevmos-smart-contract deploy HelloWorld '{\"params\":[\"Ciao Gholi\"]}' --from mykey --keyring-backend test\n```\nwhere \n- `HelloWorld` is the name of the contract\n- `'{\"params\":[\"Ciao Gholi\"]}'` is the initial parameter(s) that the constructor of the contract receives in json format. \n**Note**: It only supports basic types including numbers and strings.\n- `mykey` is the name of our key that the `init.sh` script has created for us and is funded\n\nThe output of this command is a contract address and a TX hash.\n```yaml\nContract Address:  0x4c97c555477A96D4FA14d6F2B39ea1F6cDA5082a\nTX Hash:  0x8cfb8907f6f715dc79ba7841567766b5a64505304d665628e873f1c94685f205\n```\n\nThis command has a number of flags to make it more customized if we need:\n```bash\n--algo string : The algorithm used to generate the keys (default \"eth_secp256k1\")\n--chain-id string : The evmos chain id (default \"evmos_9000-1\")\n--compiled-contracts-path string : The path to the compiled contracts in json format (default \"~/evmos-smart-contract/contracts/compiled_contracts\")\n--keyring-backend string : Keyring backend to use, default value is: os (default \"os\")\n--keyring-dir string : Keyring backend directory (default \"/home/moji/.evmosd\")\n--node string  : The evmos node to connect to (default \"http://localhost:8545\")\n```\n\n### Query a smart contract\nThe query command calls a method of a contract which only reads the state. i.e. does not change the state.\n\nHere is the usage:\n```sh\nevmos-smart-contract query [contract_name] [contract_address] [method_to_call] [method_params_json] [flags]\n```\n\nLet's read the `message` value from the `HelloWorld` contract.\n\n```bash\nevmos-smart-contract query HelloWorld 0x4c97c555477A96D4FA14d6F2B39ea1F6cDA5082a message\n```\nwhere \n- `HelloWorld` is the name of the contract\n- `0x4c97c555477A96D4FA14d6F2B39ea1F6cDA5082a` is the contract address\n- `message` is the name of the method to call\n\nHere is the example output:\n```bash\noutput: [Ciao Gholi]\n```\n\nIf we need to pass some parameters, in basic types, we can write it in json format after the name of the contract.\n\n### Send a custom transaction to a contract\nWith `tx` command we can call a method of a contract that modifies the state. Here is the usage:\n\n```sh\nevmos-smart-contract tx [contract_name] [contract_address] [method_to_call] [method_params_json] [flags]\n```\n\nLet's update the `HelloWrold` message:\n```sh\nevmos-smart-contract tx HelloWorld 0x4c97c555477A96D4FA14d6F2B39ea1F6cDA5082a update '{\"params\":[\"Ciao bello\"]}' --from mykey --keyring-backend test\n```\nThe output is some information about the transaction:\n```json\nTX Hash:  0xa55aea8053c1eb3e33fa362a812d4949bc2da2ced7af47c8be506347cfb6b10b\n{\n  \"type\": \"0x0\",\n  \"nonce\": \"0x3\",\n  \"gasPrice\": \"0xf4240\",\n  \"maxPriorityFeePerGas\": null,\n  \"maxFeePerGas\": null,\n  \"gas\": \"0x2dc6c0\",\n  \"value\": \"0x0\",\n  \"input\": \"0x3d7403a30000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a4369616f2062656c6c6f00000000000000000000000000000000000000000000\",\n  \"v\": \"0x4674\",\n  \"r\": \"0x7eb3bc59b355124bb7fc1db706537517110afaed29ed471c254b1406e0336019\",\n  \"s\": \"0xbd8f130b58ed6654112d57d3fda5d7243c11ed93edaa95858b7771212dcfb59\",\n  \"to\": \"0x4c97c555477a96d4fa14d6f2b39ea1f6cda5082a\",\n  \"hash\": \"0xa55aea8053c1eb3e33fa362a812d4949bc2da2ced7af47c8be506347cfb6b10b\"\n}\n```\n\nNow we can query the message again to see if the update is reflected properly:\n```bash\nevmos-smart-contract query HelloWorld 0x4c97c555477A96D4FA14d6F2B39ea1F6cDA5082a message\n\noutput: [Ciao bello]\n```\n\n### Transfer transfer token balances on the deployed smart contract\nTo run this command we need a smart contract with ERC20 standard. Let's deploy one.\n\n```bash\nevmos-smart-contract deploy MyTestToken --from mykey --keyring-backend test\n```\n```yaml\nContract Address:  0xe97faB40A966BF149B0926008AbA2aB854b16A1d\nTX Hash:  0x654d2b28e3bfe9a84bb781e3d86099247c49976eeb3e402d36f52e1a493db03c\n```\n\nHere is the usage of the transfer command:\n```bash\nevmos-smart-contract transfer [contract_name] [contract_address] [to_address] [amount] [flags]\n```\n\nLet's transfer some tokens:\n```sh\nevmos-smart-contract transfer MyTestToken 0xe97faB40A966BF149B0926008AbA2aB854b16A1d e0x25f59737df93dc4e1a6e55c86e87d898e8f760c1 10 --from mykey --keyring-backend test\n```\nwhere\n- `MyTestToken` is the name of the contract\n- `0xe97faB40A966BF149B0926008AbA2aB854b16A1d` is the contract address\n- `e0x25f59737df93dc4e1a6e55c86e87d898e8f760c1` is the receiver account\n- `10` is the amount to transfer\n- `mykey` is the sender account\n\nHere is the output:\n```json\nTX Hash:  0x79b17dfc8465bc092f7f4132b84e58eaed62ecab94026077e3f76f63ddb57370\n{\n  \"type\": \"0x0\",\n  \"nonce\": \"0x5\",\n  \"gasPrice\": \"0xf4240\",\n  \"maxPriorityFeePerGas\": null,\n  \"maxFeePerGas\": null,\n  \"gas\": \"0x2dc6c0\",\n  \"value\": \"0x0\",\n  \"input\": \"0xa9059cbb000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000a\",\n  \"v\": \"0x4673\",\n  \"r\": \"0x364037b33b24b70dbec42b3291f96395a2797e70629cca8a88cb05a0d3a14534\",\n  \"s\": \"0x75415693024db69df881beef0968458c2806fa84842599147e76fa4c2e1fcf50\",\n  \"to\": \"0xe97fab40a966bf149b0926008aba2ab854b16a1d\",\n  \"hash\": \"0x79b17dfc8465bc092f7f4132b84e58eaed62ecab94026077e3f76f63ddb57370\"\n}\n```\n\n### Query the token balances on the deployed smart contract\nHere is the command usage:\n```sh\nevmos-smart-contract balance [contract_name] [contract_address] [account_address] [flags]\n```\nLet's check the balance of the account that we just did the transfer to:\n```bash\nevmos-smart-contract  balance MyTestToken 0xe97faB40A966BF149B0926008AbA2aB854b16A1d e0x25f59737df93dc4e1a6e55c86e87d898e8f760c1\n```\n```yaml\nAmount: 10.000000000000000000\nDenom: MTT\n```\n\n## Test\nTo run integration test use the following command:\n```sh\nmake integration-test\n```\nIt runs a local evmos node itself and performs the tests.\n\n## Code docs\nhttps://pkg.go.dev/github.com/mojtaba-esk/evmos-smart-contract","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmojtaba-esk%2Fevmos-smart-contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmojtaba-esk%2Fevmos-smart-contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmojtaba-esk%2Fevmos-smart-contract/lists"}