After you finished coding your smart contract, the next step that we need to deploy it to EOS network (testnet or mainnet). Today I guide you step by step with full details as well as errors you could get during deploy the smart contract.
Install requirements
1. Install eos to get tools:
- cleos
- keosd
- nodeos
We will use cleos
and keosd
to create a wallet
2. Install eosio.cdt to get tools:
- eosio-cpp
- eosio-cc
- eosio-ld
- eosio-init
- eosio-abidiff
- eosio-wasm2wast
- eosio-wast2wasm
- eosio-ranlib
- eosio-ar
- eosio-objdump
- eosio-readelf
We will use eosio-cpp
to build the smart contract
3. Create a wallet
- Open a terminal, then run
keosd
firstly
$ keosd
- Secondly, open one more terminal
$ cleos wallet create -n mywallet --to-console
Creating wallet: mywallet
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5J6ULLq6efnnrwCZzkeZe9M4yLkSuZPxw6JCjMihmM7F8ojxsDq"
Keep in mind that save your password of the wallet to a safe place because one can use it the next time.
4. Import your private key to the wallet
If you do not have an account on testnet or mainnet, you have to create a new one first by going to:
Then, import your private key to the wallet:
$ cleos wallet import --private-key [your-private-key] -n mywallet
5. Complie the smart contract
Go to the smart contract source code then do:
$ eosio-cpp -I include src/mycontract.cpp -o mycontract.wasm
Deploy the smart contract
1. To the testnet
$ cleos -u https://jungle2.cryptolions.io set contract your-eos-account . mycontract.wasm mycontract.abi
2. To the mainnet
$ cleos -u https://api.main.alohaeos.com set contract your-eos-account . mycontract.wasm mycontract.abi
**Note**: There are common errors that you may get during deploy the smart contract:
- The wallet is locked.
```sh
Error 3120003: Locked wallet
Ensure that your wallet is unlocked before using it!
Error Details:
You don't have any unlocked wallet!
then you have to unlock your wallet by the password in #3 by following:
$ cleos wallet unlock -n mywallet --password PW5J6ULLq6efnnrwCZzkeZe9M4yLkSuZPxw6JCjMihmM7F8ojxsDq
- Your account has insufficient RAM.
Error 3080001: Account using more than allotted RAM usage
Error Details:
account playnwingems has insufficient ram; needs 176746 bytes has 4398 bytes
then you have to buy more RAM for your account.
$ cleos -u https://jungle2.cryptolions.io system buyram your-eos-account your-eos-account "1 EOS" -p your-eos-account
$ cleos -u https://api.main.alohaeos.com system buyram your-eos-account your-eos-account "1 EOS" -p your-eos-account
Check the smart contract
- Testnet: https://eos-test.bloks.io/
- Mainnet:https://bloks.io/
Let’s start testing your action on the smart contract!
One comment