SOLL is a new compiler for generating Ewasm (Ethereum flavored WebAssembly) files from Solidity and Yul.
To support developers as many as possible, we design projects to not only support more smart contract programming languages, such as Rust and C++ but also support various VMs, such as Ewasm VM and evm. To achieve this goal, in the very first step, we develop SOLL, a compiler for Solidity-based smart contracts running on Ewasm VM.
For application users, please refer to this document. You will know how to use SOLL to generate Ewasm bytecode from your Solidity smart contract or Yul language, and then deploy the Ewasm bytecode to Ethereum Ewasm TestNet.
For developers, we provide another document for explaining the design of SOLL and how to develop and test the functionality of SOLL, please refer to the Developer Guide for more details.
SOLL is still in an early stage, and we’ve not fully supported Solidity and Yul. Please check the features we’ve done and limitations in the following documents.
And SOLL integrates Solidity and Yul test contracts from ethereum/solidity.
Here is the pass rate of both language:
The solidity test suite (Total 80 tests from compilation tests):
Expected Passes : 27 # Solidity has 80 testing contract, and SOLL can pass 27.
Unsupported Tests : 53 # Unimplemented by SOLL
Pass Rate: 34%
Yul test suite (Total 499 tests from libyul):
Expected Passes : 393 # libyul has 499 testing contracts, and SOLL can pass 393.
Unsupported Tests : 106 # Unimplemented by SOLL
Pass Rate: 79%
To get started with our demonstration, you will need to prepare two components at first.
- Pre-install Docker and pull our docker image
We provide an image include build and execute environment (recommend). If you don't want to use docker directly you will need below tools (cmake, llvm, binaryen, xxd, wabt, node.js).
-
If you want to set up the working environment by yourself, please install the following dependencies:
- Our docker image is based on Ubuntu 20.04
- llvm-10-dev
- llvm-10-tools
- liblld-10-dev
- cmake
- make
- wget
- python-psutil
- binaryen
- wabt
- clang-10 or g++-9
-
After SOLL 0.1.1, we use llvm-10 instead of llvm-8, if you want to build the older version of SOLL, please use this docker image:
secondstate/soll:0.1.0
.
- Pull official docker image to get an already established build/execute environment.
> docker pull secondstate/soll
- Get Source Code from Github and checkout to the latest version, 0.1.1.
> git clone --recursive https://github.com/second-state/soll.git
> cd soll
> git checkout 0.1.1
Attach shell to container and bind volume with repositories' path.
> docker run -it --rm \
-v $(pwd)/soll:/root/soll \
secondstate/soll
Build SOLL(we use cmake with llvm library)
(docker) $ cd ~/soll && mkdir -p build && cd build
(docker) $ cmake .. && make
Our original tutorial will deploy Ewasm bytecode on the official TestNet. Unfortunately, the Ewasm TestNet is unavailable now. We’ve moved the original tutorial into Deploy an ERC20 smart contract to Ewasm official TestNet.
For demonstration propose, we provide another Ewasm TestNet which is launched by our DevChain.
DevChain The Second State DevChain features a powerful and easy-to-use virtual machine that can quickly get you started with smart contracts and DApp development. Our devchain supports Ewasm by hera through EVMC interface.
SOLL supports two frontend languages including Solidity and Yul. You can use SOLL to generate Ewasm bytecode(.wasm) directly.
Create your smart contract files by copying from our demonstration contract "0-0-3.sol". And execute SOLL to generate Ewasm bytecode(.wasm) and contract ABI.
(docker) $ cd ~
(docker) $ cp ~/soll/docs/examples/0-0-3.sol ~/0-0-3.sol
(docker) $ ~/soll/build/tools/soll/soll 0-0-3.sol
# The output bytecode is loacted at ~/0-0-3.wasm
# You will need ABI information for interacting with smart contract
(docker) $ ~/soll/build/tools/soll/soll --action=EmitABI 0-0-3.sol
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[{"name":"account","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"}]
We will use "0-0-3.wasm" in the next section to deploy it to Ewasm TestNet.
Create your smart contract files by copying from our demonstration contract "0-0-6.yul". And execute SOLL to generate Ewasm bytecode(.wasm) and contract ABI.
(docker) $ cd ~
(docker) $ cp ~/soll/docs/examples/0-0-6.yul ~/0-0-6.yul
(docker) $ ~/soll/build/tools/soll/soll -lang=Yul 0-0-6.yul
# The output bytecode is loacted at ~/0-0-6.wasm
# 0-0-6.yul is compiled from 0.0.3.sol via Solc. You can retrieve ABI of 0-0-6.yul by the following command:
(docker) $ ~/soll/build/tools/soll/soll --action=EmitABI 0-0-3.sol
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[{"name":"account","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"}]
We will use "0-0-6.wasm" in the next section to deploy it to Ewasm TestNet.
(soll docker) $ xxd -p ~/soll/docs/examples/0-0-3.wasm | tr -d $'\n'
The result should be the same as the following content. (This will be used later)
0061736d0100000001270760027f7f0060000060017f0060037f7f7f0060057f7e7e7e7e0060047e7f7f7f017f6000017e02c7010908657468657265756d0c67657443616c6c56616c7565000208657468657265756d0c73746f7261676553746f7265000008657468657265756d0967657443616c6c6572000208657468657265756d0a6765744761734c656674000608657468657265756d0a63616c6c537461746963000508657468657265756d0e72657475726e44617461436f7079000308657468657265756d0b73746f726167654c6f6164000008657468657265756d06726576657274000008657468657265756d0666696e697368000003040304010105030100020608017f0141e0ad040b071102066d656d6f72790200046d61696e000b0abf0d038d0300200020044228884280fe03832004421888428080fc0783200442088842808080f80f8320044208864280808080f01f832004421886428080808080e03f83200442288642808080808080c0ff00832004423886200442388884848484848484370300200041186a20014228884280fe03832001421888428080fc0783200142088842808080f80f8320014208864280808080f01f832001421886428080808080e03f83200142288642808080808080c0ff00832001423886848484848484200142388884370300200020024228884280fe03832002421888428080fc0783200242088842808080f80f8320024208864280808080f01f832002421886428080808080e03f83200242288642808080808080c0ff00832002423886848484848484200242388884370310200020034228884280fe03832003421888428080fc0783200342088842808080f80f8320034208864280808080f01f832003421886428080808080e03f83200342288642808080808080c0ff008320034238868484848484842003423888843703080ba00a02067f087e23004190026b220024002000220141c8016a100020012903c801200141d0016a29030084500440200041606a220322022400200241606a220422052400200241786a4280808080d0a0fdf000370300200241706a4200370300200241686a420037030020044200370300200041786a4200370300200041706a4200370300200041686a4200370300200342003703002003200410012005220041606a2202220324002000416c6a41edde013b0100200041686a220441e5dc91aa06360200200242c5a48d928386d5b7eb00370300200041786a220220022903004280808080808080801c84220637030020042903002107200041706a29030021082003220041606a220322022400200241606a220422052400200241786a2006370300200241706a2008370300200241686a2007370300200442c5a48d928386d5b7eb00370300200041786a42808080808080808001370300200041706a4200370300200041686a4200370300200342003703002003200410012005220041606a220222032400200041626a41c4003a0000200241c5a8013b0100200041786a220420042903004280808080808080800684220637030020022903002107200041686a2903002108200041706a29030021092003220041606a220322022400200241606a220422052400200241786a2006370300200241706a2009370300200241686a200837030020042007370300200041786a42808080808080808002370300200041706a4200370300200041686a4200370300200342003703002003200410012005220041606a22022203240020021002200141a8016a4200200229030022064220862006422088200041686a290300220642208684200041706a350200422086200642208884100920014188016a20012903a801200141b0016a290300200141b8016a3502004200100920014190016a290300210620014198016a2903002107200141a0016a290300210820012903880121092003220041406a220222032400200041786a42808080808080808003370300200041706a4200370300200041686a4200370300200041606a4200370300200041586a2008370300200041506a2007370300200041486a2006370300200220093703002001420037038002200142003703f801200142808080103e0288021003200141f8016a200241c00010041a200141d8016a410041201005200141e8006a20012903d801200141e0016a290300200141e8016a290300200141f0016a290300100920014180016a2903002106200141f8006a2903002107200141f0006a2903002108200129036821092003220041606a220322022400200241606a220422052400200041786a4200370300200041706a4200370300200041686a420037030020034200370300200320041006200141c8006a2004290300200241686a290300200241706a290300200241786a2903001009200141286a20092008200720061009200141306a2903002106200141386a2903002107200141406b290300210820012903282109200141086a2001290348200141d0006a290300200141d8006a290300200141e0006a2903001009200141106a290300210a200141186a290300210b200141206a290300210c2001290308210d2005220041606a220322022400200241606a22042400200241786a200c370300200241706a200b370300200241686a200a3703002004200d370300200041786a2008370300200041706a2007370300200041686a20063703002003200937030020032004100120014190026a24000f0b41800841171007000b0c00100a41970841c42510080b0be32501004180080bdb2546756e6374696f6e206973206e6f742070617961626c650061736d0100000001460b60027f7f0060017f0060037f7f7f0060000060077f7f7f7f7f7f7f0060047f7e7e7e0060057f7e7e7e7e0060077e7e7e7e7e7e7e006000017f60047e7f7f7f017f6000017e0289020c08657468657265756d0c67657443616c6c56616c7565000108657468657265756d0a6765744761734c656674000a08657468657265756d0a63616c6c537461746963000908657468657265756d0e72657475726e44617461436f7079000208657468657265756d0b73746f726167654c6f6164000008657468657265756d06726576657274000008657468657265756d0967657443616c6c6572000108657468657265756d0c73746f7261676553746f7265000008657468657265756d036c6f67000408657468657265756d0f67657443616c6c4461746153697a65000808657468657265756d0c63616c6c44617461436f7079000208657468657265756d0666696e69736800000305040605070305030100020608017f0141f088040b071102066d656d6f72790200046d61696e000f0ac321048d0300200020044228884280fe03832004421888428080fc0783200442088842808080f80f8320044208864280808080f01f832004421886428080808080e03f83200442288642808080808080c0ff00832004423886200442388884848484848484370300200041186a20014228884280fe03832001421888428080fc0783200142088842808080f80f8320014208864280808080f01f832001421886428080808080e03f83200142288642808080808080c0ff00832001423886848484848484200142388884370300200020024228884280fe03832002421888428080fc0783200242088842808080f80f8320024208864280808080f01f832002421886428080808080e03f83200242288642808080808080c0ff00832002423886848484848484200242388884370310200020034228884280fe03832003421888428080fc0783200342088842808080f80f8320034208864280808080f01f832003421886428080808080e03f83200342288642808080808080c0ff008320034238868484848484842003423888843703080baf0402057f017e230041d0016b22052400200522044188016a100020042903880120044190016a29030084500440200441e8006a20012002200342ffffffff0f834200100c200441f0006a2903002101200441f8006a290300210220044180016a290300210320042903682109200541406a220622072400200541786a42808080808080808003370300200541706a4200370300200541686a4200370300200541606a4200370300200541586a2003370300200541506a2002370300200541486a200137030020062009370300200442003703c001200442003703b801200442808080103e02c8011001200441b8016a200641c00010021a20044198016a410041201003200441c8006a200429039801200441a0016a290300200441a8016a290300200441b0016a290300100c200441286a2004290348200441d0006a290300200441d8006a290300200441e0006a290300100c200441306a2903002101200441386a2903002102200441406b2903002103200429032821092007220541606a220722062400200641606a22082400200541786a2003370300200541706a2002370300200541686a200137030020072009370300200720081004200441086a2008290300200641686a290300200641706a290300200641786a290300100c200441106a2903002101200441186a290300210220042903082103200041186a200441206a290300370300200020023703102000200137030820002003370300200441d0016a24000f0b41d90841171005000bec1502077f0b7e230041d0056b22082400200822074188056a1000024002400240024020072903880520074190056a29030084500440200841606a2209220b240020091006200741e8046a42002009290300220e422086200e422088200841686a290300220e42208684200841706a350200422086200e42208884100c200741c8046a20072903e804200741f0046a290300200741f8046a3502004200100c200741d0046a290300210e200741d8046a290300210f200741e0046a290300211020072903c8042112200b220841406a2209220a2400200841786a42808080808080808003370300200841706a4200370300200841686a4200370300200841606a4200370300200841586a2010370300200841506a200f370300200841486a200e37030020092012370300200742003703c005200742003703b805200742808080103e02c8051001200741b8056a200941c00010021a20074198056a410041201003200741a8046a200729039805200741a0056a220b290300200741a8056a220c290300200741b0056a220d290300100c200741c0046a2903002111200741b8046a2903002113200741b0046a290300211420072903a8042115200a220841606a2209220a24002009100620074188046a42002009290300220e422086200e422088200841686a290300220e42208684200841706a350200422086200e42208884100c200741e8036a20072903880420074190046a29030020074198046a3502004200100c200741f0036a290300210e200741f8036a290300210f20074180046a290300211020072903e8032112200a220841406a2209220a2400200841786a42808080808080808003370300200841706a4200370300200841686a4200370300200841606a4200370300200841586a2010370300200841506a200f370300200841486a200e37030020092012370300200742003703c005200742003703b805200742808080103e02c8051001200741b8056a200941c00010021a20074198056a410041201003200741c8036a200729039805200b290300200c290300200d290300100c200741a8036a20072903c803200741d0036a290300200741d8036a290300200741e0036a290300100c200741b0036a290300210e200741b8036a290300210f200741c0036a290300211020072903a8032112200a220841606a220a22092400200941606a220c220d2400200841786a2010370300200841706a200f370300200841686a200e370300200a2012370300200a200c100420074188036a200c290300200941686a290300200941706a290300200941786a290300100c200741a0036a290300210e20074198036a290300210f20074190036a2903002110200729038803211220074198056a1000200729039805200b290300844200520d0120122003542208201020045420042010511b2209200f200554220b200e2006542006200e511b2005200f852006200e8584501b0d02200741e8026a2015201420132011100c200741f0026a2903002111200741f8026a290300211320074180036a290300211420072903e8022115200741c8026a201220037d201020047d2008ad7d200f20057d220f2009ad22107d200e20067d200bad7d200f201054ad7d100c200741d0026a290300210e200741d8026a290300210f200741e0026a290300211020072903c8022112200d220841606a220b22092400200941606a220a220c2400200941786a2010370300200941706a200f370300200941686a200e370300200a2012370300200841786a2014370300200841706a2013370300200841686a2011370300200b2015370300200b200a1007200741a8026a20002001200242ffffffff0f834200100c200741b0026a2903002110200741b8026a2903002112200741c0026a290300210020072903a8022101200c220841406a2209220a2400200841786a42808080808080808003370300200841706a4200370300200841686a4200370300200841606a4200370300200841586a2000370300200841506a2012370300200841486a201037030020092001370300200742003703c005200742003703b805200742808080103e02c8051001200741b8056a200941c00010021a20074198056a41004120100320074188026a200729039805200741a0056a220b290300200741a8056a220c290300200741b0056a220d290300100c200741a0026a290300211420074198026a290300211520074190026a29030021162007290388022117200a220841406a2209220a2400200841786a42808080808080808003370300200841706a4200370300200841686a4200370300200841606a4200370300200841586a2000370300200841506a2012370300200841486a201037030020092001370300200742003703c005200742003703b805200742808080103e02c8051001200741b8056a200941c00010021a20074198056a410041201003200741e8016a200729039805200b290300200c290300200d290300100c200741c8016a20072903e801200741f0016a290300200741f8016a29030020074180026a290300100c200741d0016a290300210e200741d8016a290300210f200741e0016a290300210220072903c8012111200a220841606a220a22092400200941606a220c220d2400200841786a2002370300200841706a200f370300200841686a200e370300200a2011370300200a200c1004200741a8016a200c290300200941686a290300200941706a290300200941786a290300100c200741c0016a290300210e200741b8016a290300210f200741b0016a290300210220072903a801211120074198056a1000200729039805200b290300844200520d03200320117c221820115422082008ad200220047c7c221320025420022013511b22082005200f7c22112008ad7c2202200f542002201154ad2011200f54ad2006200e7c7c7c2211200e54200e2011511b2002200f85200e20118584501b0d0420074188016a2017201620152014100c20074190016a290300210e20074198016a290300210f200741a0016a29030021142007290388012115200741e8006a2018201320022011100c200741f0006a2903002102200741f8006a290300211120074180016a290300211320072903682116200d220841606a220b22092400200941606a220a220c2400200941786a2013370300200941706a2011370300200941686a2002370300200a2016370300200841786a2014370300200841706a200f370300200841686a200e370300200b2015370300200b200a1007200c220841606a2209220b240020091006200741c8006a42002009290300220e422086200e422088200841686a290300220e42208684200841706a350200422086200e42208884100c200741d0006a290300210e200741d8006a350200210f20072903482102200b220841606a2209220b2400200741286a2002200e200f4200100c200741306a290300210e200741386a290300210f20072903282102200841786a200741406b290300370300200841706a200f370300200841686a200e37030020092002370300200b220841606a220b220a2400200841786a2000370300200841706a2012370300200841686a2010370300200b2001370300200a220841606a220a2400200741086a2003200420052006100c200741106a2903002106200741186a290300210420072903082105200841786a200741206a290300370300200841706a2004370300200841686a2006370300200a2005370300200a412041034180082009200b41001008200741d0056a24000f0b41d90841171005000b41d90841171005000b41bb08411e1005000b41d90841171005000b41a008411b1005000b920402047f047e230041a0016b2200210120002400024002400240100941034d0d00200041706a220022022400200041004104100a2000280200220041a98bf0dc7b460d01200041f0c08a8c03470d002002220041606a220222032400200241044120100a200141406b2002290300200041686a290300200041706a290300200041786a290300100c200141206a2001290340200141c8006a290300200141d0006a350200100d20012001290320200141286a290300200141306a290300200141386a290300100c200141086a2903002104200141106a2903002105200141186a2903002106200129030021072003220041606a22022400200041786a2006370300200041706a2005370300200041686a20043703002002200737030020024120100b0c020b41004100100b0c010b2002220041406a2202220324002002410441c000100a20014180016a2002290300200041486a290300200041506a290300200041586a290300100c200141e0006a200041606a290300200041686a290300200041706a290300200041786a290300100c20012903800120014188016a29030020014190016a3502002001290360200141e8006a290300200141f0006a290300200141f8006a290300100e2003220041606a22022400200041786a42808080808080808001370300200041706a4200370300200041686a42003703002002420037030020024120100b0b200141a0016a24000b0b7701004180080b70ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef536166654d6174683a206164646974696f6e206f766572666c6f77536166654d6174683a207375627472616374696f6e206f766572666c6f7746756e6374696f6e206973206e6f742070617961626c65
(soll docker) $ xxd -p ~/soll/docs/examples/0-0-6.wasm | tr -d $'\n'
The result should be the same as the following content. (This will be used later)
0061736d0100000001270760027f7f0060000060017f0060037f7f7f0060057f7e7e7e7e0060047e7f7f7f017f6000017e02c7010908657468657265756d0c67657443616c6c56616c7565000208657468657265756d06726576657274000008657468657265756d0a6765744761734c656674000608657468657265756d0a63616c6c537461746963000508657468657265756d0e72657475726e44617461436f7079000308657468657265756d0b73746f726167654c6f6164000008657468657265756d0666696e697368000008657468657265756d0967657443616c6c6572000208657468657265756d0c73746f7261676553746f7265000003040304010105030100020608017f014190e0040b071102066d656d6f72790200046d61696e000b0afa0e038d0300200020044228884280fe03832004421888428080fc0783200442088842808080f80f8320044208864280808080f01f832004421886428080808080e03f83200442288642808080808080c0ff00832004423886200442388884848484848484370300200041186a20014228884280fe03832001421888428080fc0783200142088842808080f80f8320014208864280808080f01f832001421886428080808080e03f83200142288642808080808080c0ff00832001423886848484848484200142388884370300200020024228884280fe03832002421888428080fc0783200242088842808080f80f8320024208864280808080f01f832002421886428080808080e03f83200242288642808080808080c0ff00832002423886848484848484200242388884370310200020034228884280fe03832003421888428080fc0783200342088842808080f80f8320034208864280808080f01f832003421886428080808080e03f83200342288642808080808080c0ff008320034238868484848484842003423888843703080be30b02057f087e23004180036b220121002001240041e8e004428080808080808080807f37030041e0e004420037030041d8e004420037030041d0e004420037030041800829030042df005641880829030022054200522005501b419008290300220642005241980829030022054200522005501b2005200684501b4504404198084200370300419008420037030041880842003703004180084280013703000b2001220241706a2201240020011000200041c8016a420042002001290300200241786a290300100920002903c801200041d0016a29030084504504404190e004410010010b200041f8026a22014200370300200042003703f002200042003703e802200042003703e002200041e0026a200041c0026a100520004198026a4280808080d0a0fdf000370300200041b8026a4200370300200042003703900220004200370388022000420037038002200042003703b002200042003703a802200042003703a002200041a0026a20004180026a100820014200370300200042003703f002200042003703e802200042003703e002200041e0026a200041c0026a1005200041a8016a20002903c002200041c8026a290300200041d0026a290300200041d8026a2903001009200041c0016a2903002106200041b8016a2903002109200041b0016a290300210a20002903a801210b200041e8016a100720004188016a420020002903e80122054220862005422088200041f0016a290300220542208684200041f8016a3502004220862005422088841009200041e8006a20002903880120004190016a29030020004198016a3502004200100941a8e00420004180016a29030037030041a0e004200041f8006a2903003703004198e004200041f0006a2903003703004190e004200029036837030002404180082903002207421f564188082903002205420052220120055022021b419008290300220842005241980829030022054200522005501b220320052008845022041b45044041c8e0044280808080808080800137030041c0e004420037030041b8e004420037030041b0e004420037030041980842003703004190084200370300418808420037030041800842c0003703000c010b41c8e0044280808080808080800137030041c0e004420037030041b8e004420037030041b0e00442003703002007423f56200120021b200320041b0d0041980842003703004190084200370300418808420037030041800842e0003703000b200042003703c802200042003703c002200042808080103e02d0021002200041c0026a4190e00441c00010031a200041e0026a410041201004200041c8006a20002903e002200041e8026a290300200041f0026a290300200041f8026a22012903001009200041286a2000290348200041d0006a290300200041d8006a290300200041e0006a29030010092001200041406b29030022053703002000200041386a29030022083703f0022000200041306a29030022073703e80220002000290328220c3703e002200041e0026a200041c0026a1005200041086a200b200a200920061009200041b8026a200537030020004198026a200041206a290300370300200020083703b002200020073703a8022000200c3703a0022000200041186a290300370390022000200041106a290300370388022000200029030837038002200041a0026a20004180026a100841800829030042e8d7005641880829030022054200522005501b419008290300220642005241980829030022054200522005501b2005200684501b4504404198084200370300419008420037030041880842003703004180084280d8003703000b4190e00441003a000041012101034020014190e0046a200141a0086a2d00003a0000200141e8d70046450440200141016a21010c010b0b41800829030042e8d7005641880829030022054200522005501b419008290300220642005241980829030022054200522005501b2005200684501b4504404198084200370300419008420037030041880842003703004180084280d8003703000b4190e00441e9d700100620004180036a24000b0400100a0b0bf057010041a1080be85761736d0100000001400a60027f7f0060057f7e7e7e7e0060000060017f0060037f7f7f0060077f7f7f7f7f7f7f0060087e7e7e7e7e7e7e7e006000017f60047e7f7f7f017f6000017e0289020c08657468657265756d0f67657443616c6c4461746153697a65000708657468657265756d0c63616c6c44617461436f7079000408657468657265756d0c67657443616c6c56616c7565000308657468657265756d06726576657274000008657468657265756d0a6765744761734c656674000908657468657265756d0a63616c6c537461746963000808657468657265756d0e72657475726e44617461436f7079000408657468657265756d0b73746f726167654c6f6164000008657468657265756d0666696e697368000008657468657265756d0967657443616c6c6572000308657468657265756d0c73746f7261676553746f7265000008657468657265756d036c6f67000503070601020601010205030100020608017f0141a088040b071102066d656d6f72790200046d61696e00110ae554068d0300200020044228884280fe03832004421888428080fc0783200442088842808080f80f8320044208864280808080f01f832004421886428080808080e03f83200442288642808080808080c0ff00832004423886200442388884848484848484370300200041186a20014228884280fe03832001421888428080fc0783200142088842808080f80f8320014208864280808080f01f832001421886428080808080e03f83200142288642808080808080c0ff00832001423886848484848484200142388884370300200020024228884280fe03832002421888428080fc0783200242088842808080f80f8320024208864280808080f01f832002421886428080808080e03f83200242288642808080808080c0ff00832002423886848484848484200242388884370310200020034228884280fe03832003421888428080fc0783200342088842808080f80f8320034208864280808080f01f832003421886428080808080e03f83200342288642808080808080c0ff008320034238868484848484842003423888843703080ba61a02057f0e7e230041e0046b220121002001240041f88804428080808080808080807f37030041f08804420037030041e88804420037030041e08804420037030041800829030042df005641880829030022054200522005501b419008290300220642005241980829030022054200522005501b2005200684501b4504404198084200370300419008420037030041880842003703004180084280013703000b024010004104490d00200141606a220222032400200241004120100120004180046a2002290300200141686a290300200141706a290300200141786a290300100c0240024002400240200028029c04220141bbb996c87a470440200141b184828507470d052003220241706a2201240020011002200041a0026a420042002001290300200241786a290300100c20002903a002200041a8026a290300845045044041a08804410010030b1000ad2205427c7c2206421f5620062005542201ad427f7c220542005220055022021b2001410020021b2201ad2205427f7c2206420052200620055a20062005541b20011b45044041a08804410010030b200041c0046a41044120100120004180026a20002903c004200041c8046a290300200041d0046a290300200041d8046a290300100c20004188026a29030021062000290380022107410020004190026a290300220542808080801054410020004198026a2903002208501b200542808080801085200884501b45044041a08804410010030b200041e0016a20072006200542ffffffff0f834200100c41b88804200041f8016a29030037030041b08804200041f0016a29030037030041a88804200041e8016a29030037030041a0880420002903e0013703004180082903002207421f564188082903002205420052220120055022021b419008290300220642005241980829030022054200522005501b220320052006845022041b0d0141d888044280808080808080800137030041d08804420037030041c88804420037030041c08804420037030041980842003703004190084200370300418808420037030041800842c0003703000c020b2003220241706a2201240020011002200041e0036a420042002001290300200241786a290300100c20002903e003200041e8036a290300845045044041a08804410010030b1000ad2205427c7c2206423f5620062005542201ad427f7c220542005220055022021b2001410020021b2201ad2205427f7c2206420052200620055a20062005541b20011b45044041a08804410010030b200041c0046a410441201001200041c0036a20002903c004200041c8046a2201290300200041d0046a2202290300200041d8046a2203290300100c200041c8036a290300210720002903c00321084100200041d0036a2903002205428080808010544100200041d8036a2903002206501b200542808080801085200684501b45044041a08804410010030b200041c0046a412441201001200041a0036a20002903c004200129030020022903002003290300100c200820072005200620002903a003200041a8036a290300200041b0036a290300200041b8036a290300100e20004180036a41e0880429030041e8880429030041f0880429030041f88804290300100c20004198036a290300210b20004190036a290300210720004188036a29030021092000290380032106418008290300220d42df005641880829030022084200522008501b419008290300220a42005241980829030022054200522005501b2005200a84501b450440419808420037030041900842003703004188084200370300428001210d418008428001370300420021084200210a420021050b20094200522007420052200b420052200b501b2007200b84501b450d0241a0880441001003418008290300210d4188082903002108419008290300210a4198082903002105200041c0026a200620092007200b100c41f88804200041d8026a29030037030041f08804200041d0026a29030037030041e88804200041c8026a29030037030041e0880420002903c002370300200d42df005620084200522008501b200a42005220054200522005501b2005200a84501b0d03419808420037030041900842003703004188084200370300428001210d418008428001370300420021084200210a420021050c030b41d888044280808080808080800137030041d08804420037030041c88804420037030041c0880442003703002007423f56200120021b200320041b0d0041980842003703004190084200370300418808420037030041800842e0003703000b200042003703a804200042003703a004200042808080103e02b0041004200041a0046a41a0880441c00010051a200041c0046a410041201006200041c0016a20002903c004200041c8046a290300200041d0046a290300200041d8046a2201290300100c200041a0016a20002903c001200041c8016a290300200041d0016a290300200041d8016a290300100c2001200041b8016a2903003703002000200041b0016a2903003703d0042000200041a8016a2903003703c804200020002903a0013703c004200041c0046a200041a0046a100720004180016a20002903a004200041a8046a290300200041b0046a290300200041b8046a290300100c20004198016a290300210c20004190016a290300210e20004188016a290300210f2000290380012110200041e0006a41e0880429030041e8880429030041f0880429030041f88804290300100c200041f8006a290300210b200041f0006a2903002107200041e8006a290300210920002903602106418008290300220d42df0056418808290300220a420052200a501b419008290300220842005241980829030022054200522005501b2005200884501b450440419808420037030041900842003703004188084200370300428001210d4180084280013703004200210a42002108420021050b024020094200522007420052200b420052200b501b2007200b84501b044041a0880441001003418008290300210d418808290300210a41900829030021084198082903002105200041206a200620092007200b100c41f88804200041386a29030037030041f08804200041306a29030037030041e88804200041286a29030037030041e088042000290320370300200d42df0056200a420052200a501b200842005220054200522005501b2005200884501b0d01419808420037030041900842003703004188084200370300428001210d4180084280013703004200210a42002108420021050c010b200041406b200620092007200b100c41f88804200041d8006a29030037030041f08804200041d0006a29030037030041e88804200041c8006a29030037030041e0880420002903403703000b20002010200f200e200c100c2006a7220141b888046a200041186a290300370300200141b088046a200041106a290300370300200141a888046a200041086a290300370300200141a088046a22022000290300370300200b2007200642407d220f200654220120092001ad7c2210200954200f20065a1bad7c2211200754ad7c22122005200642207c220e200d562009200e2006542201ad7c220c200a56200a200c511b20072001200c200954200e20065a1bad7c2209200856200b2009200754ad7c220620055620052006511b2008200985200520068584501b22011b21052011200820011b21072010200a20011b2108200f426083220b200d20011b210a02402001450440200e200a58200c2008582008200c511b2009200758200620055820052006511b2007200985200520068584501b0d010b41980820122005200e200a56200c2008562008200c511b2009200756200620055620052006511b2007200985200520068584501b22011b3703004190082011200720011b3703004188082010200820011b370300418008200b200a20011b3703000b2002412010080c020b200041e0026a200620092007200b100c41f88804200041f8026a29030037030041f08804200041f0026a29030037030041e88804200041e8026a29030037030041e0880420002903e0023703000b2006a7220141b888046a42808080808080808001370300200141b088046a4200370300200141a888046a4200370300200141a088046a22024200370300200b2007200642407d220f200654220120092001ad7c2210200954200f20065a1bad7c2211200754ad7c22122005200642207c220e200d562009200e2006542201ad7c220c2008562008200c511b20072001200c200954200e20065a1bad7c2209200a56200b2009200754ad7c220620055620052006511b2009200a85200520068584501b22011b21052011200a20011b21072010200820011b2108200f426083220b200d20011b210a02402001450440200e200a58200c2008582008200c511b2009200758200620055820052006511b2007200985200520068584501b0d010b41980820122005200e200a56200c2008562008200c511b2009200756200620055620052006511b2007200985200520068584501b22011b3703004190082011200720011b3703004188082010200820011b370300418008200b200a20011b3703000b2002412010080b410041001008200041e0046a24000bbd2c02067f127e230041e0076b220b2400200b220841c8066a1009200841a8066a420020082903c806220e422086200e422088200841d0066a290300220e42208684200841d8066a350200422086200e42208884100c20084188066a20082903a806200841b0066a290300200841b8066a3502004200100c41b88804200841a0066a29030037030041b0880420084198066a29030037030041a8880420084190066a29030037030041a0880420082903880637030002404180082903002214421f56418808290300220e4200522209200e50220a1b419008290300220f420052419808290300220e420052200e501b220d200e200f8450220c1b45044041d888044280808080808080800137030041d08804420037030041c88804420037030041c08804420037030041980842003703004190084200370300418808420037030041800842c0003703000c010b41d888044280808080808080800137030041d08804420037030041c88804420037030041c0880442003703002014423f562009200a1b200d200c1b0d0041980842003703004190084200370300418808420037030041800842e0003703000b200842003703a807200842003703a007200842808080103e02b0071004200841a0076a41a0880441c00010051a200841c0076a410041201006200841e8056a20082903c007200841c8076a290300200841d0076a290300200841d8076a2209290300100c200841c8056a20082903e805200841f0056a290300200841f8056a29030020084180066a290300100c2009200841e0056a2903003703002008200841d8056a2903003703d0072008200841d0056a2903003703c807200820082903c8053703c007200841c0076a200841a0076a1007200841a8056a20082903a007200841a8076a290300200841b0076a290300200841b8076a290300100c20082903a805221e20045a200841b0056a290300221420055a2005201451220a1b200841b8056a290300221520065a200841c0056a290300221120075a20072011511b2006201585200720118584501b45044020084188056a41e0880429030041e8880429030041f0880429030041f88804290300100c200841a0056a290300211720084198056a290300211320084190056a2903002116200829038805210e418008290300221842df005641880829030022104200522010501b4190082903002212420052419808290300220f420052200f501b200f201284501b4504404200211041980842003703004190084200370300418808420037030042800121184180084280013703004200210f420021120b200ea7220941b888046a4200370300200941b088046a4200370300200941a888046a4200370300200941a088046a220d428886e7830a370300200e42207c221920185820162019200e54220cad7c221a2010582010201a511b2013200c201a2016542019200e5a1bad7c221920125820172019201354ad7c221a200f58200f201a511b2012201985200f201a8584501b450440418008200e42407d220f42608322183703004188082016200f200e54220cad7c22103703004190082013200c2010201654200f200e5a1bad7c221237030041980820172012201354ad7c220f3703000b200941bc88046a42808080808080808020370300200941b488046a4200370300200941ac88046a4200370300200941a488046a4200370300200e42247c221920185820162019200e542209ad7c221820105820102018511b2013200920182016542019200e5a1bad7c221020125820172010201354ad7c221a200f58200f201a511b2010201285200f201a8584501b450440418008200e42c4007c220f4260833703004188082016200f200e542209ad7c2212370300419008201320092012201654200f200e5a1bad7c220f3703004198082017200f201354ad7c3703000b200841e8046a201920182010201a100f20082903e804220f200e7d2116200f41800829030058200841f0046a2903002210418808290300220e58200e2010511b200841f8046a290300221241900829030022175820084180056a290300220e419808290300221358200e2013511b2012201785200e20138584501b450440418008200f42207c221342608337030041880820102013200f542209ad7c22173703004190082012200920172010542013200f5a1bad7c220f370300419808200e200f201254ad7c3703000b200d2016a7100341a08804410010030b200b220941606a220b220d2400200b1009200841c8046a4200200b290300220e422086200e422088200941686a290300220e42208684200941706a350200422086200e42208884100c200841a8046a20082903c804200841d0046a290300200841d8046a3502004200100c41b88804200841c0046a29030037030041b08804200841b8046a29030037030041a88804200841b0046a29030037030041a0880420082903a804370300201520067d220e201e20045422092014200554200a1bad220f7d2110201120077d2015200654ad7d200e200f54ad7d2115201420057d2009ad7d2111201e20047d211202404180082903002213421f56418808290300220f420052200f5022091b4190082903002214420052419808290300220e420052200e50220b1b200e20148450220a1b45044041d888044280808080808080800137030041d08804420037030041c88804420037030041c08804420037030041980842003703004190084200370300418808420037030041800842c0003703000c010b41d888044280808080808080800137030041d08804420037030041c88804420037030041c0880442003703002013423f56200f42005220091b2014420052200e420052200b1b200a1b0d0041980842003703004190084200370300418808420037030041800842e0003703000b200842003703a807200842003703a007200842808080103e02b0071004200841a0076a41a0880441c00010051a200841c0076a41004120100620084188046a20082903c007200841c8076a290300200841d0076a290300200841d8076a2209290300100c200841e8036a20082903880420084190046a29030020084198046a290300200841a0046a290300100c200920084180046a290300220e3703002008200841f8036a290300220f3703d0072008200841f0036a29030022143703c807200820082903e80322133703c007200841c0076a200841a0076a1007200841c8036a2012201120102015100c20084198076a200e370300200841f8066a200841e0036a2903003703002008200f37039007200820143703880720082013370380072008200841d8036a2903003703f0062008200841d0036a2903003703e806200820082903c8033703e00620084180076a200841e0066a100a200841a8036a20002001200242ffffffff0f834200100c41b88804200841c0036a290300221e37030041b08804200841b8036a290300221737030041a88804200841b0036a290300221837030041a0880420082903a803221937030002404180082903002214421f56418808290300220e4200522209200e50220b1b419008290300220f420052419808290300220e420052200e501b220a200e200f8450220c1b45044041d888044280808080808080800137030041d08804420037030041c88804420037030041c08804420037030041980842003703004190084200370300418808420037030041800842c0003703000c010b41d888044280808080808080800137030041d08804420037030041c88804420037030041c0880442003703002014423f562009200b1b200a200c1b0d0041980842003703004190084200370300418808420037030041800842e0003703000b200842003703a807200842003703a007200842808080103e02b0071004200841a0076a41a0880441c00010051a200841c0076a41004120100620084188036a20082903c007200841c8076a290300200841d0076a290300200841d8076a2209290300100c200841e8026a20082903880320084190036a29030020084198036a290300200841a0036a290300100c200920084180036a2903003703002008200841f8026a2903003703d0072008200841f0026a2903003703c807200820082903e8023703c007200841c0076a200841a0076a1007200841c8026a20082903a007200841a8076a290300200841b0076a290300200841b8076a290300100c20082903c80222152004427f8558200841d0026a29030022142005427f85220e58200e2014511b200841d8026a290300220f2006427f85221058200841e0026a290300220e2007427f85221158200e2011511b200f201085200e20118584501b45044041a08804410010030b200420157c221a20155422092009ad200520147c7c221620145420142016511b22092006200f7c22152009ad7c2214200f542014201554ad2015200f54ad2007200e7c7c7c2215200e54200e2015511b200f201485200e20158584501b4101460440200841a8026a41e0880429030041e8880429030041f0880429030041f88804290300100c200841c0026a290300211b200841b8026a2903002112200841b0026a290300211320082903a802210e418008290300221f42df005641880829030022114200522011501b4190082903002210420052419808290300220f420052200f501b200f201084501b450440419808420037030041900842003703004188084200370300428001211f41800842800137030042002111420021104200210f0b200ea7220941b888046a4200370300200941b088046a4200370300200941a888046a4200370300200941a088046a220b428886e7830a370300200e42207c221c201f582013201c200e54220aad7c221d2011582011201d511b2012200a201d201354201c200e5a1bad7c221c201058201b201c201254ad7c221d200f58200f201d511b2010201c85200f201d8584501b450440418008200e42407d220f426083221f3703004188082013200f200e54220aad7c22113703004190082012200a2011201354200f200e5a1bad7c2210370300419808201b2010201254ad7c220f3703000b200941bc88046a42808080808080808020370300200941b488046a4200370300200941ac88046a4200370300200941a488046a4200370300200e42247c221c201f582013201c200e542209ad7c221f2011582011201f511b20122009201f201354201c200e5a1bad7c2211201058201b2011201254ad7c221d200f58200f201d511b2010201185200f201d8584501b450440418008200e42c4007c220f4260833703004188082013200f200e542209ad7c2210370300419008201220092010201354200f200e5a1bad7c220f370300419808201b200f201254ad7c3703000b20084188026a201c201f2011201d1010200829038802220f200e7d2113200f4180082903005820084190026a2903002211418808290300220e58200e2011511b20084198026a2903002210419008290300221b58200841a0026a290300220e419808290300221258200e2012511b2010201b85200e20128584501b450440418008200f42207c221242608337030041880820112012200f542209ad7c221b37030041900820102009201b2011542012200f5a1bad7c220f370300419808200e200f201054ad7c3703000b200b2013a710030b41a08804201937030041a88804201837030041b08804201737030041b88804201e37030002404180082903002211421f56418808290300220e4200522209200e50220b1b419008290300220f420052419808290300220e420052200e501b220a200e200f8450220c1b45044041d888044280808080808080800137030041d08804420037030041c88804420037030041c08804420037030041980842003703004190084200370300418808420037030041800842c0003703000c010b41d888044280808080808080800137030041d08804420037030041c88804420037030041c0880442003703002011423f562009200b1b200a200c1b0d0041980842003703004190084200370300418808420037030041800842e0003703000b200842003703a807200842003703a007200842808080103e02b0071004200841a0076a41a0880441c00010051a200841c0076a410041201006200841e8016a20082903c007200841c8076a290300200841d0076a290300200841d8076a2209290300100c200841c8016a20082903e801200841f0016a290300200841f8016a29030020084180026a290300100c2009200841e0016a290300220e3703002008200841d8016a290300220f3703d0072008200841d0016a29030022113703c807200820082903c80122103703c007200841c0076a200841a0076a1007200841a8016a201a201620142015100c20084198076a200e370300200841f8066a200841c0016a2903003703002008200f37039007200820113703880720082010370380072008200841b8016a2903003703f0062008200841b0016a2903003703e806200820082903a8013703e00620084180076a200841e0066a100a200d220941606a220b220a2400200b100920084188016a4200200b290300220e422086200e422088200941686a290300220e42208684200941706a350200422086200e42208884100c20084190016a290300211920084198016a350200211a200829038801211b200841e8006a41e0880429030041e8880429030041f0880429030041f88804290300100c20084180016a2903002113200841f8006a2903002111200841f0006a29030021102008290368210f418008290300221242df005641880829030022144200522014501b4190082903002215420052419808290300220e420052200e501b200e201584501b450440419808420037030041900842003703004188084200370300428001211241800842800137030042002114420021154200210e0b200841c8006a2004200520062007100c200fa7220941b888046a200841e0006a290300370300200941b088046a200841d8006a290300370300200941a888046a200841d0006a290300370300200941a088046a220c200829034837030020132011200f42407d2205200f54220920102009ad7c22162010542005200f5a1bad7c221e201154ad7c211720054260832118200f42207c220420125820102004200f542209ad7c220620145820062014511b2011200920062010542004200f5a1bad7c220720155820132007201154ad7c2205200e582005200e511b20072015852005200e8584501b45044041800820183703004188082016370300419008201e37030041980820173703002018211220162114201e21152017210e0b200a220941606a220b220a2400200941786a42a8eaebead4fec8d96f370300200941706a4295d79c8dbf8cf1d016370300200941686a42e984c3c5c6ffcdc6aa7f370300200b42dde5cbeabac3b8e49b7f370300200a220941606a220a220d2400200841286a201b2019201a4200100c200841306a290300210f200841386a290300211120082903282110200941786a200841406b290300370300200941706a2011370300200941686a200f370300200a2010370300200d220941606a220d2400200841086a2000200120022003100c200841106a290300210f200841186a290300211120082903082110200941786a200841206a290300370300200941706a2011370300200941686a200f370300200d20103703002004201258200620145820062014511b20072015582005200e582005200e511b20072015852005200e8584501b45044041800820183703004188082016370300419008201e37030041980820173703000b200c41204103200b200a200d4100100b200841e0076a24000bb40502047f0b7e230041406a22072106200724002001a7220541b888046a4280808080808080801e370300200541b088046a4200370300200541a888046a4200370300200541a088046a420037030020042003200142407d220e200154220520022005ad7c220c200254200e20015a1bad7c220d200354ad7c210a200142207c2210418008290300221158200220102001542205ad7c2209418808290300220b582009200b511b200320052009200254201020015a1bad7c2212419008290300220f5820042012200354ad7c221341980829030022095820092013511b200f201285200920138584501b450440418808200c370300418008200e4260832211370300419008200d370300419808200a370300200c210b200d210f200a21090b2007220541606a220724002005417c6a41efee013b0100200541786a220841e5e499e306360200200541706a42e3e8a5fbe68dc8b7f600370300200541686a42bac0ccaba78c9db9e100370300200742d3c299abd6a998bae800370300200641206a42d3c299abd6a998bae80042bac0ccaba78c9db9e10042e3e8a5fbe68dc8b7f6002008290300100c20062006290320200641286a290300200641306a290300200641386a290300100c2010a7220541b888046a200641186a290300370300200541b088046a200641106a290300370300200541a888046a200641086a290300370300200541a088046a2006290300370300200e201158200c200b58200b200c511b200d200f58200a2009582009200a511b200d200f852009200a8584501b450440418008200142e0007c2209426083370300418808200220092001542205ad7c220b37030041900820032005200b200254200920015a1bad7c220137030041980820042001200354ad7c3703000b2000200e3703002000200c3703082000200d370310200041186a200a370300200641406b24000bb10502047f0b7e230041406a22072106200724002001a7220541b888046a4280808080808080801b370300200541b088046a4200370300200541a888046a4200370300200541a088046a420037030020042003200142407d220e200154220520022005ad7c220c200254200e20015a1bad7c220d200354ad7c210a200142207c2210418008290300221158200220102001542205ad7c2209418808290300220b582009200b511b200320052009200254201020015a1bad7c2212419008290300220f5820042012200354ad7c221341980829030022095820092013511b200f201285200920138584501b450440418808200c370300418008200e4260832211370300419008200d370300419808200a370300200c210b200d210f200a21090b2007220541606a220724002005417a6a41f7003a0000200541786a220841ecde013b0100200541706a42efdc81f9e6ae99b9e600370300200541686a42bac084a3c6ac9abae900370300200742d3c299abd6a998bae800370300200641206a42d3c299abd6a998bae80042bac084a3c6ac9abae90042efdc81f9e6ae99b9e6002008290300100c20062006290320200641286a290300200641306a290300200641386a290300100c2010a7220541b888046a200641186a290300370300200541b088046a200641106a290300370300200541a888046a200641086a290300370300200541a088046a2006290300370300200e201158200c200b58200b200c511b200d200f58200a2009582009200a511b200d200f852009200a8584501b450440418008200142e0007c2209426083370300418808200220092001542205ad7c220b37030041900820032005200b200254200920015a1bad7c220137030041980820042001200354ad7c3703000b2000200e3703002000200c3703082000200d370310200041186a200a370300200641406b24000b0400100d0b
Then exit SOLL container goto next step.
- Pull our devchain docker image.
> docker pull secondstate/devchain:devchain
- Attach to testnet
> docker run -it secondstate/devchain:devchain attach https://rpc.parastate.io:8545
Welcome to the Travis JavaScript console!
instance: vm/v1.9.2/linux-amd64/go1.10.3
coinbase: 0x7eff122b94897ea5b0e2a9abf47b86337fafebdc
at block: 1115129 (Tue, 07 Apr 2020 06:51:46 UTC)
modules: cmt:1.0 eth:1.0 net:1.0 personal:1.0 rpc:1.0 web3:1.0
- Unlock the demo account with a long expiration time.
> personal.unlockAccount(cmt.accounts[0], '1234', 9999999)
Please note: You can obtain network tokens (STATE tokens) for the aforementioned ParaState Testnet by visiting the testnet's faucet at https://testnet.faucet.parastate.io:8001/faucet.
There is also a YouTube Video which demonstrates how to use the faucet.
- Deploy Ewasm bytecode generated from 0-0-3.sol that has been seen before.
// Paste your bytecode from previous section.
> var bytecode = "0x...";
// Set first account as the transaction sender
> var fromAccount = personal.listAccounts[0];
// Set contract ABI. Copy from the previous section.
> var abi = [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[{"name":"account","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"}]
// Initialize contract template
> var contract = cmt.contract(abi);
// Initialize contractAddress for storing address of deployed contract.
> var contractAddress = "0x";
// Initialize txhash for storing transaction hash of deployed contract.
> var txhash = "0x";
// Create deployment parameters
> var params = {
from: fromAccount,
data: bytecode,
gas: 5000000
};
// Deploy smart contract
> contract.new(params,
function(error, result){
if(error) {
console.log("Deploy failed");
} else {
if (result.address) {
contractAddress = result.address;
console.log("Contract Address: " + contractAddress);
} else {
txhash = result.transactionHash;
console.log("txhash: " + txhash);
}
}
});
// The result should be a random hash similar to the following content.
txhash: 0x37da6061b71f8cfae71ed8e5f020b54ad805d457be4f4530b36298d6b6ad0c56
{
abi: [{
inputs: [],
payable: false,
stateMutability: "nonpayable",
type: "constructor"
}, {
payable: true,
stateMutability: "payable",
type: "fallback"
}, {
constant: true,
inputs: [{...}],
name: "balanceOf",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: false,
inputs: [{...}, {...}],
name: "transfer",
outputs: [{...}],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
anonymous: false,
inputs: [{...}, {...}, {...}],
name: "Transfer",
type: "event"
}],
address: undefined,
transactionHash: "0x37da6061b71f8cfae71ed8e5f020b54ad805d457be4f4530b36298d6b6ad0c56"
}
Contract Address: 0xb606a9622b2dd1fbca5b0eece5c454260e3adaf7
- Check the transaction receipt of contract deployment.
> cmt.getTransactionReceipt(txhash)
// The result should similar to the following content.
{
blockHash: "0xcfea68349c8d30261256130769eb46fdd927391a1f989c86900fc4085319018a",
blockNumber: 1115248,
contractAddress: "0xb606a9622b2dd1fbca5b0eece5c454260e3adaf7",
cumulativeGasUsed: 1519352,
from: "0x7eff122b94897ea5b0e2a9abf47b86337fafebdc",
gasUsed: 1519352,
logs: [],
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
status: "0x1",
to: null,
transactionHash: "0x37da6061b71f8cfae71ed8e5f020b54ad805d457be4f4530b36298d6b6ad0c56",
transactionIndex: 0
}
- You can check the contract deployed was success by getCode(contract address)
> cmt.getCode(contractAddress)
// The result should similar to the following content.
"0x0061736d01000000..." (omitted, runtime Ewasm bytecode)
-
Send the transaction to execute a contract function
transfer
. In this example, we want to transfer 123 tokens from account A to account B -
Setup transaction parameters:
// Get contract instance via contract address
> var contractInstance = contract.at(contractAddress);
// Setup transaction parameters
> var txnObject = {
from: fromAccount,
gas: 5000000
};
// Set second account as token receiver
> var toAccount = personal.listAccounts[1];
// Set send 123 tokens
> var sendValue = 123
- Before we send the transaction, checking their balances first.
// Get original balance of fromAccount and toAccount
> contractInstance.balanceOf.call(fromAccount);
100000000
> contractInstance.balanceOf.call(toAccount);
0
- Call ERC20.transfer(receiver, value)
> contractInstance.transfer.sendTransaction(toAccount, sendValue, txnObject,
function(error, result){
if(error){
console.log("Error: " + error);
} else {
txhash = result;
console.log("txhash: " + txhash);
}
});
// The result should similar to the following content.
txhash: 0x566211fa5850ad759c001941eec060f48e0108eac06bbbeb17ad08684cf6c9d9
- Check their balances again.
// Get after balance of fromAccount and toAccount
> contractInstance.balanceOf.call(fromAccount);
99999877
> contractInstance.balanceOf.call(toAccount);
123
- Verfiy
transfer
by getTransactionReceipt.
> cmt.getTransactionReceipt(txhash)
// The result should similar to the following content.
// The logs section will show that we emit an event in the `transfer` function.
{
blockHash: "0x8e4e1f7bd15ec484f4e161b97be4b2de08072a4cdca0f617ec7023de9c878e6c",
blockNumber: 1116022,
contractAddress: null,
cumulativeGasUsed: 38225,
from: "0x7eff122b94897ea5b0e2a9abf47b86337fafebdc",
gasUsed: 38225,
logs: [{
address: "0xb606a9622b2dd1fbca5b0eece5c454260e3adaf7",
blockHash: "0x8e4e1f7bd15ec484f4e161b97be4b2de08072a4cdca0f617ec7023de9c878e6c",
blockNumber: 1116022,
data: "0x000000000000000000000000000000000000000000000000000000000000007b",
logIndex: 0,
removed: false,
topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x0000000000000000000000007eff122b94897ea5b0e2a9abf47b86337fafebdc", "0x00000000000000000000000077beb894fc9b0ed41231e51f128a347043960a9d"],
transactionHash: "0x566211fa5850ad759c001941eec060f48e0108eac06bbbeb17ad08684cf6c9d9",
transactionIndex: 0
}],
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000010000000000000000000000100000000010000000000000000000000800000000000000001000000000000080000000000000000000000000000000000000000000001000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000",
status: "0x1",
to: "0xb606a9622b2dd1fbca5b0eece5c454260e3adaf7",
transactionHash: "0x566211fa5850ad759c001941eec060f48e0108eac06bbbeb17ad08684cf6c9d9",
transactionIndex: 0
}
All steps are the same with 3.4.4-1. You only need to replace the Ewasm bytecode with 0-0-6.wasm.
(Omitted)