Run the node:
cd ethermint
./init.sh
Shell
Get the validator wallet:
$ ethermintd keys unsafe-export-eth-key mykey --keyring-backend test
516E8F2A291E39158E5FAAA9282147D44EEFA0C0EF1E65A1C925114F5CCDCA43
Shell
Import the wallet on Metamask:
Metamask.
To import the wallet just paste your private key on metamask.
Add Ethermint rpc:
Ethermint rpc details.
Use remix to deploy a contract
Go to Remix.
Add your .sol file to the contracts folder.
Go to SOLIDITY COMPILER and compile your contract.
Go to DEPLOY & RUN TRANSACTIONS and select Injected Web3.
Select your contract and press Deploy
You can play using Remix with your contract or save your deployed address to sent transitions using etherumjs-tx.
Etherumjs-tx example:
Create a node project:
npm init
npm install etherumjs-tx
touch main.js
Shell
Create a transaction to use the contract:
const Tx = require('ethereumjs-tx').Transaction
var privateKey = new Buffer('516E8F2A291E39158E5FAAA9282147D44EEFA0C0EF1E65A1C925114F5CCDCA43', 'hex')
const txData = {
nonce: '0x02',
gasPrice: '0x14',NOTE: set your current nonce, the private key should be the same used for Metamask and the TO address must be the one where the contract is deployed.
gasLimit: '0xffff',
to: '0x71dda21734De2D4Db99EB07634F67B57D25cC728',
data: '0x00',
};
const tx = new Tx(txData);
tx.sign(privateKey)
var serializedTx = tx.serialize()
console.log(serializedTx.toString('hex'))
JavaScript
main.js
NOTE: set your current nonce, the private key should be the same used for Metamask and the TO address must be the one where the contract is deployed.
Extras:
Javascript example project:
This example deploys a contract and calls some methods. It uses etherumjs-tx lib and gets the keys using the ethermint-cli.
Contract example:
pragma solidity ^0.5.11;
contract Counter {
uint256 counter = 0;
function add() public {
counter++;
}
function subtract() public {
counter--;
}
function getCounter() public view returns (uint256) {
return counter;
}
}
Plain Text
Simple counter.sol example