{"id":13621022,"url":"https://github.com/tintinweb/solidity-shell","last_synced_at":"2025-04-13T00:43:05.090Z","repository":{"id":38446622,"uuid":"401311920","full_name":"tintinweb/solidity-shell","owner":"tintinweb","description":"An interactive Solidity Shell","archived":false,"fork":false,"pushed_at":"2023-05-28T13:40:11.000Z","size":1306,"stargazers_count":545,"open_issues_count":5,"forks_count":30,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-13T00:43:01.484Z","etag":null,"topics":["ethereum","repl","shell","solidity","solidity-compiler"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/solidity-shell","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tintinweb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-30T11:02:09.000Z","updated_at":"2025-03-31T07:30:15.000Z","dependencies_parsed_at":"2024-06-21T15:22:36.635Z","dependency_job_id":"2786e710-b3ae-4c59-b8a9-4957d925a1e6","html_url":"https://github.com/tintinweb/solidity-shell","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tintinweb%2Fsolidity-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tintinweb%2Fsolidity-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tintinweb%2Fsolidity-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tintinweb%2Fsolidity-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tintinweb","download_url":"https://codeload.github.com/tintinweb/solidity-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650418,"owners_count":21139672,"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":["ethereum","repl","shell","solidity","solidity-compiler"],"created_at":"2024-08-01T21:01:01.835Z","updated_at":"2025-04-13T00:43:05.064Z","avatar_url":"https://github.com/tintinweb.png","language":"JavaScript","readme":"[\u003cimg width=\"200\" alt=\"get in touch with Consensys Diligence\" src=\"https://user-images.githubusercontent.com/2865694/56826101-91dcf380-685b-11e9-937c-af49c2510aa0.png\"\u003e](https://diligence.consensys.net)\u003cbr/\u003e\n\u003csup\u003e\n[[  🌐  ](https://diligence.consensys.net)  [  📩  ](https://github.com/ConsenSys/vscode-solidity-doppelganger/blob/master/mailto:diligence@consensys.net)  [  🔥  ](https://consensys.github.io/diligence/)]\n\u003c/sup\u003e\u003cbr/\u003e\u003cbr/\u003e\n\n\n## Solidity Shell\n\nAn interactive Solidity shell with lightweight session recording and remote compiler support.\n\n[💾](https://www.npmjs.com/package/solidity-shell) `npm install -g solidity-shell` \n\n```javascript\n⇒  solidity-shell\n \n🚀 Entering interactive Solidity shell. '.help' and '.exit' are your friends.\n »  ℹ️  ganache-mgr: starting temp. ganache instance ...\n »\n »  uint a = 100\n »  uint b = 200\n »  a + b + 2 + uint8(50)\n352\n »  $_\n352\n```\n\nOh, did you know that we automatically fetch a matching remote compiler when you change the solidity pragma? It is as easy as typing `pragma solidity 0.5.0` and solidity-shell will do the rest 🙌.\n\n\n\n### Hints\n\n* `pragma solidity \u003cversion\u003e` attempts to dynamically load the selected compiler version (remote compiler, may take a couple of seconds).\n* use `{ \u003cstatement\u003e; }` to ignore a calls return value. \n* Sessions can be saved and restored using the `.session` command. Your previous session is always stored and can be loaded via `.session load previous` (not safe when running concurrent shells).\n* `.reset` completely removes all statements. `.undo` removes the last statement.\n* See what's been generated under the hood? call `.dump`.\n* Settings are saved on exit (not safe when running concurrent shells). call `config set \u003ckey\u003e \u003cvalue\u003e` to change settings like ganache port, ganache autostart, etc.\n* `$_` is a placeholder for the last known result. Feel free to use that placeholder in your scripts :)\n* Special commands are dot-prefixed. Everything else is evaluated as Solidity code.\n* `import \"\u003cpath\u003e\"` assumes that `path` is relative to the current working-dir (CWD) or `{CWD}/node_modules/`. There's experimental support for HTTPs URL's. You can disable https resolving by setting ` »  .config set resolveHttpImports false`.\n    \n```solidity\n »  import \"https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC721/IERC721.sol\"\n```\n\n\n### Usage\n\n#### Cmdline Passthru\n\nAny arguments provided after an empty `--` are directly passed to `ganacheCmd` (default: `ganache-cli`). This way, for example, you can start a solidity shell on a ganache fork of mainnet via infura. Check `ganache-cli --help` for a list of available options.\n\n```shell\n⇒  solidity-shell -- --fork https://mainnet.infura.io/v3/yourApiToken\n \n🚀 Entering interactive Solidity shell. Type '.help' for help, '.exit' to exit.\n »  ℹ️  ganache-mgr: starting temp. ganache instance ...\n »\n »  interface ERC20 {\nmulti\u003e function name() external view returns (string memory);\nmulti\u003e }\n \n »  ERC20(0xB8c77482e45F1F44dE1745F52C74426C631bDD52).name()\nBNB\n\n```\n\n#### Repl\n\n```shell\n🚀 Entering interactive Solidity ^0.8.11 shell. '.help' and '.exit' are your friends.\n »  ℹ️  ganache-mgr: starting temp. ganache instance ...\n »\n »  .help\n\n📚 Help:\n   -----\n\n $_ is a placeholder holding the most recent evaluation result.\n pragma solidity \u003cversion\u003e to change the compiler version.\n\n\n General:\n    .help                                ... this help :)\n    .exit                                ... exit the shell\n\n\n Source:\n    .fetch \n            interface \u003caddress\u003e \u003cname\u003e [chain=mainnet] ... fetch and load an interface declaration from an ABI spec on etherscan.io\n    .inspect\n            bytecode                     ... show bytecode of underlying contract\n            opcodes                      ... show disassembled opcodes of underlying contract\n            storageLayout                ... show variable to storage slot mapping for underlying contract\n            storage \u003cslot\u003e \u003cnum\u003e [\u003caddress\u003e] ... show raw storage at slot of underlying deployed contract \n            deployed                     ... debug: show internal contract object\n\n\n Blockchain:\n    .chain                         \n            restart                      ... restart the blockchain service\n            set-provider \u003cfork-url\u003e      ... \"internal\" | \u003cshell-command: e.g. ganache-cli\u003e | \u003chttps://localhost:8545\u003e\n                                            - fork url e.g. https://mainnet.infura.io/v3/yourApiKey  \n            accounts                     ... return eth_getAccounts\n            eth_\u003cX\u003e [...args]            ... initiate an arbitrary eth JSONrpc method call to blockchain provider.\n\n Settings:\n    .config                              ... show settings\n            set \u003ckey\u003e \u003cvalue\u003e            ... set setting\n            unset \u003ckey\u003e                  ... unset setting\n Session:\n    .session                             ... list sessions\n            load \u003cid\u003e                    ... load session\n            save \u003cid\u003e                    ... save session\n    .undo                                ... undo last command\n    .reset                               ... reset cmd history. start from scratch.\n\n Debug:\n    .proc                                ... show processes managed by solidity-shell (ganache)\n    .dump                                ... show template contract\n    .echo                                ... every shell needs an echo command\n\n\ncheers 🙌 \n    @tintinweb \n    ConsenSys Diligence @ https://consensys.net/diligence/\n    https://github.com/tintinweb/solidity-shell/ \n\n```\n\n## Examples \n\n\n![solidity-shell](https://user-images.githubusercontent.com/2865694/131328119-e363f20a-f627-43fc-8801-8d6613ad740f.gif)\n\n\n### Transaction vars: `msg.sender` etc.\n\n```javascript\n »  msg.sender\n0x70e9B09abd6A13D2F5083CD5814076b77427199F\n »  address(uint160(address(msg.sender)))\n0x70e9B09abd6A13D2F5083CD5814076b77427199F\n```\n\n### Contracts, Structs, Functions\n\n```javascript\n⇒  solidity-shell\n \n🚀 Entering interactive Solidity shell. Type '.help' for help, '.exit' to exit.\n »  ℹ️  ganache-mgr: starting temp. ganache instance ...\n »\n »  contract TestContract {}\n »  new TestContract()\n0xFBC1B2e79D816E36a1E1e923dd6c6fad463F4368\n »  msg.sender\n0x363830C6aee2F0c43922bcB785C570a7cca613b5\n »  block.timestamp\n1630339581\n »  struct yolo {uint8 x; uint8 y;}\n »  function mytest(uint x) public pure returns(uint) {\nmulti\u003e return x -5;\nmulti\u003e }\n »  mytest(100)\n95\n```\n\n![solidity-shell2](https://user-images.githubusercontent.com/2865694/131328490-e211e89b-ac59-4729-972b-3e3b19b75cfc.gif)\n\n### Advanced usage\n\n```javascript\n »  struct yolo {uint8 x; uint8 y;}\n »  .dump\n// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.7;\n\ncontract TestContract {}\n\nstruct yolo {uint8 x; uint8 y;}\n\ncontract MainContract {\n\n    \n\n    function main() public  {\n        uint a = 100;\n        uint b = 200;\n        a + b + 2 + uint8(50);\n        new TestContract();\n        msg.sender;\n        block.timestamp;\n        return ;\n    }\n}\n```\n\n### Fetch Interface Declaration from Etherscan\n\n![shell-fetch-interface](https://user-images.githubusercontent.com/2865694/183062446-c952b308-9fc7-49f9-8308-3eac09ca3b4a.gif)\n\n\n`.fetch interface \u003caddress\u003e \u003cinterfaceName\u003e [optional: chain=mainnet]`\n\n```\n⇒  solidity-shell --fork https://mainnet.infura.io/v3/\u003cyourApiKey\u003e                                                                                                \n \n🚀 Entering interactive Solidity ^0.8.16 shell (🧁:Ganache built-in). '.help' and '.exit' are your friends.\n »  \n »  .fetch interface 0x40cfEe8D71D67108Db46F772B7e2CD55813Bf2FB Test\n »  interface Test {\n    \n    ... omitted ...\n\n    function symbol() external view returns (string memory);\n\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n\n    function totalSupply() external view returns (uint256);\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    function transferOwnership(address newOwner) external;\n\n    function withdraw() external;\n}\n\n »  Test t = Test(0x40cfEe8D71D67108Db46F772B7e2CD55813Bf2FB)\n »  t.symbol()\nMGX\n```\n\n### Inspect Contract Storage on Ganache Fork\n\n1. Run solidity shell in **fork-mode**.\n2. Display contract storage at latest block.\n\n\n```\n⇒  solidity-shell --fork https://mainnet.infura.io/v3/\u003cyourApiKey\u003e    \n\n🚀 Entering interactive Solidity ^0.8.16 shell (🧁:Ganache built-in, ⇉ fork-mode). '.help' and '.exit' are your friends.\n »  .inspect storage 0 10 0x40cfEe8D71D67108Db46F772B7e2CD55813Bf2FB\n »  \n     📚 Contract:      0x40cfee8d71d67108db46f772b7e2cd55813bf2fb @ latest block\n\n     slot              1f 1e 1d 1c 1b 1a 19 18 17 16 15 14 13 12 11 10 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00\n  --------------------------------------------------------------------------------------------------------------------\n  0x000000 (   0)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1d c7    ................................\n  0x000001 (   1)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000002 (   2)      54 68 65 20 4d 61 67 69 78 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12    The Magix.......................\n  0x000003 (   3)      4d 47 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06    MGX.............................\n  0x000004 (   4)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000005 (   5)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000006 (   6)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000007 (   7)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000008 (   8)      00 00 00 00 00 00 00 00 00 00 00 00 d7 4e 84 57 2f 5f 7b 5d 41 47 4e be d9 b3 02 0a 2e 52 6f c6    .............N.W/_{]AGN......Ro.\n  0x000009 (   9)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 0f    ..............................'.\n```\n\n### Inspect Generated Contract\n\n```\n  solidity-shell       \n \n🚀 Entering interactive Solidity ^0.8.16 shell (🧁:Ganache built-in, ⇉ fork-mode). '.help' and '.exit' are your friends.\n »  1+1\n2\n »  .inspect bytecode\n6080604052348015610010576000 ... 03a7bab64736f6c63430008100033\n »  .inspect opcodes\nPUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE ... SLOAD 0xDA POP GASPRICE PUSH28 0xAB64736F6C6343000810003300000000000000000000000000000000 \n »  .inspect storageLayout\n{ storage: [], types: null }\n »  .inspect storage 0 4\n »  \n     📚 Contract:      0xCa1061046396daF801dEB0D848FcfeA055fAfBFC @ latest block\n\n     slot              1f 1e 1d 1c 1b 1a 19 18 17 16 15 14 13 12 11 10 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00\n  --------------------------------------------------------------------------------------------------------------------\n  0x000000 (   0)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000001 (   1)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000002 (   2)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n  0x000003 (   3)      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................................\n```\n\n____\n\n\n## Acknowledgements\n\n* Inspired by the great but unfortunately unmaintained [solidity-repl](https://github.com/raineorshine/solidity-repl).\n* Fetch interfaces from Etherscan is powered by [abi-to-sol](https://github.com/gnidan/abi-to-sol).\n","funding_links":[],"categories":["Tools","JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftintinweb%2Fsolidity-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftintinweb%2Fsolidity-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftintinweb%2Fsolidity-shell/lists"}