<divclass="link title"><ahref="/v5/">Documentation</a></div><divclass="base show link depth-1"><ahref="/v5/getting-started/">Getting Started</a></div><divclass="base show link depth-1"><ahref="/v5/concepts/">Ethereum Basics</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/events/">Events</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/gas/">Gas</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/security/">Security</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/best-practices/">Best Practices</a></div><divclass="base show link depth-1"><ahref="/v5/api-keys/">Provider API Keys</a></div><divclass="base show link depth-1"><ahref="/v5/api/">Application Programming Interface</a></div><divclass="hide link depth-2"><ahref="/v5/api/providers/">Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/provider/">Provider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/api-providers/">API Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/other/">Other Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/types/">Types</a></div><divclass="hide link depth-2"><ahref="/v5/api/signer/">Signers</a></div><divclass="hide link depth-2"><ahref="/v5/api/contract/">Contract Interaction</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract/">Contract</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract-factory/">ContractFactory</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><divclass="hide link depth-2"><ahref="/v5/api/utils/">Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/abi/">Application Binary Interface</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/coder/">AbiCoder</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/formats/">ABI Formats</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/fragments/">Fragments</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/interface/">Interface</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/address/">Addresses</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bignumber/">BigNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bytes/">Byte Manipulation</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/constants/">Constants</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/display-logic/">Display Logic and Input</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/encoding/">Encoding Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hashing/">Hashing Algorithms</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hdnode/">HD Wallet</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/logger/">Logging</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/properties/">Property Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/signing-key/">Signing Key</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/strings/">Strings</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/transactions/">Transactions</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/web/">Web Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/wordlists/">Wordlists</a></div><divclass="hide link depth-2"><ahref="/v5/api/other/">Other Libraries</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/assembly/">Assembly</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/api/">Utilities</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/ast/
<divclass="breadcrumbs"><ahref="/v5/">Documentation</a> » <ahref="/v5/cli/">Command Line Interfaces</a> » <spanclass="current">Sandbox Utility</span></div>
<aname="sandbox-utility"></a><h1class="show-anchors"><div>Sandbox Utility<divclass="anchors"><aclass="self"href="/v5/cli/ethers/#sandbox-utility"></a></div></div></h1><p>The sandbox utility provides a simple way to use the most common ethers utilities required during learning, debugging and managing interactions with the Ethereum network.</p>
(*) By including mnemonics or private keys on the command line they are
possibly readable by other users on your system and may get stored in
your bash history file. This is NOT recommended.</div><aname="sandbox-utility--examples"></a><h2class="show-anchors"><div>Examples<divclass="anchors"><aclass="self"href="/v5/cli/ethers/#sandbox-utility--examples"></a></div></div></h2>
<aname="cliex-init"></a><divclass="code-title"><div>Creating New Wallets</div></div><divclass="code">/home/ethers> ethers init wallet.json
Creating a new JSON Wallet - wallet.json
Keep this password and file SAFE!! If lost or forgotten
it CANNOT be recovered, by ANYone, EVER.
Choose a password: ******
Confirm password: ******
Encrypting... 100%
New account address: 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Saved: wallet.json
# If you are planning to try out the Ropsten testnet...
/home/ethers> ethers --network ropsten fund 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Transaction Hash: 0x8dc55b8f8dc8076acded97f9e3ed7d6162460c0221e2769806006b6d7d1156e0</div><aname="cliex-send"></a><divclass="code-title"><div>Sending Ether and Tokens</div></div><divclass="code"># Sending ether
recid: 0</div><aname="cliex-scripting"></a><aname="sandbox-utility--examples--cliex-scripting"></a><h3class="show-anchors"><div>Scripting<divclass="anchors"><aclass="self"href="/v5/cli/ethers/#cliex-scripting"></a></div></div></h3><p>The <codeclass="inline">eval</code> command can be used to execute simple one-line scripts from the command line to be passed into other commands or stored in script environment variables.</p>
<divclass="code-title"><div>Get the formatted balance of an account</div></div><divclass="code">/home/ethers> ethers --network ropsten \
3.141592653589793238</div><divclass="code-title"><div>Get the current block number</div></div><divclass="code">/home/ethers> ethers --network rinkeby \
eval "provider.getBlockNumber()"
5761009</div><divclass="code-title"><div>Convert a Solidity signature to JSON</div></div><divclass="code">/home/ethers> ethers eval 'utils.Fragment.from(
"function balanceOf(address) view returns (uint)"
).format("json")' | json_pp
{
"inputs" : [
{
"type" : "address",
"name" : "owner"
}
],
"type" : "function",
"payble" : false,
"stateMutability" : "view",
"ouputs" : [
{
"type" : "uint256"
}
],
"name" : "balanceOf",
"constant" : true
}</div><divclass="code-title"><div>Compute a topic hash</div></div><divclass="code">/home/ricmoo> ethers eval 'id("Transfer(address,address,uint256")'
0xd99659a21de82e379975ce8df556f939a4ccb95e92144f38bb0dd35730ffcdd5</div><divclass="code-title"><div>Create a random mnemonic</div></div><divclass="code">/home/ricmoo> ethers eval 'Wallet.createRandom().mnemonic'
useful pond inch knock ritual matrix giggle attend dilemma convince coach amazing</div><aname="cliex-mnemonicpassword"></a><aname="sandbox-utility--examples--cliex-mnemonicpassword"></a><h3class="show-anchors"><div>Using Mnemonics (with a password)<divclass="anchors"><aclass="self"href="/v5/cli/ethers/#cliex-mnemonicpassword"></a></div></div></h3><p>All mnemonic phrases have a password, but the default is to use the empty string (i.e. <codeclass="inline">""</code>) as the password. If you have a password on your mnemonic, the <codeclass="inline">--mnemonic-password</code> will prompt for the password to use to decrypt the account.</p>
homestead></div><aname="cliex-mnemonicpassword-xxx"></a><aname="sandbox-utility--examples--cliex-mnemonicpassword-xxx"></a><h3class="show-anchors"><div>Using Mnemonics (with experimental memory-hard passwords)<divclass="anchors"><aclass="self"href="/v5/cli/ethers/#cliex-mnemonicpassword-xxx"></a></div></div></h3><p>The <codeclass="inline">--xxx-mnemonic-password</code> is similar to the <codeclass="inline">--mnemonic-password</code> options, which uses a password to decrypt the account for a mnemonic, however it passes the password through the <ahref="https://en.wikipedia.org/wiki/Scrypt">scrypt</a><i>password-based key derivation function</i> first, which is intentionally slow and makes a brute-force attack far more difficult.</p>
homestead></div><divclass="definition container-box warning"><divclass="term">Note</div><divclass="body"><p>This is still an experimental feature (hence the <codeclass="inline">xxx</code>).</p>
</div></div>
<divclass="footer">
<divclass="nav previous"><ahref="/v5/cli/"><spanclass="arrow">←</span>Command Line Interfaces</a></div>
<divclass="copyright">The content of this site is licensed under the <ahref="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on February 8, 2021, 3:25pm.</div>