Dev.Series — Create a Greeter Smart Contract on evan.network
In this blogpost we will show you how simple it is to deploy a hello world contract in the evan.network.
Create a Profile on the Network
Go to https://dashboard.evan.network and there you can create a new profile on the evan.network. You have two options to identify yourself. You can use our personal wallet to generate a new account, import a existing account or use MetaMask to create only a profile on evan.network.
When you choose “A New Identity”, the application shows you your newly created 12 seed words. Store this seed words in a safe place. When you loose it, no one can recover your account … not even chuck norris.
Afterwards you must verfiy that you have stored your seed phrase … so simply repeat it and fill the empty boxes. When you verified your phrase you must accept our Terms and Conditions, since we’re currently on the testnet the terms are very small. The captcha checkbox must be checked because we don’t want any bots in our network, unless its your own bot.
evan.network ❤LOVES❤ bots but they must be owned and developed by a real person.
When all these steps are done, your personal profile will be created especially for you. It can take a few seconds to create the profile, so be patient.
You will receive 5 Test EVE on your account to play around a little bit. If you want more, join
You will be forwarded to your personal dashboard of the evan.network. The features and how you can add your own dapps to the dashboard, will be explained in the next blogpost on the medium channel.
Now you can use your account to create contracts and do transactions on them. You can export your private key for the account on the “profile” Dapp. To deploy contracts you can use your favorite tool like remix or truffle or something else.
Setup Remix and Metamask
To deploy the contract on evan.network, we will now use Remix in combination with Metamask.
You can connect Metamask when you click on the icon on the top of your browser and click on the network and select “Special RPC”. Insert the address https://testcore.evan.network to connect to the evan.network rpc.
Now you can import your previous created private key as new account within metmask.
When you have done this, you can open Remix https://remix.ethereum.org/. This is a IDE for solidity based ethereum smart contracts.
You can create a new contract with the “+” icon on the top left of the UI. Name it “Greeter.sol” and save the file.
Deploy a contract via Remix
Now paste the content of the contract into the editor, it will automatically store the file in your local browser storage:
contract Mortal {
/* Define variable owner of the type address */
address owner;
/* This function is executed at initialization and sets the owner of the contract */
function Mortal() { owner = msg.sender; }/* Function to recover the funds on the contract */
function kill() { if (msg.sender == owner) selfdestruct(owner); }
}contract Greeter is Mortal {
/* Define variable greeting of the type string */
string greeting;/* This runs when the contract is executed */
function Greeter(string _greeting) public {
greeting = _greeting;
}/* Main function */
function greet() constant returns (string) {
return greeting;
}
}
If you want to deploy this sample greeter contract now to the evan.network, you can switch to the “Run” tab on the right side of Remix. Make sure that you have selected the environment “Injected Web3” and the account matches the account you previously imported.
Now pass a greeting to the contract as constructor parameter and click on the button “Deploy” to create the contract.
After you’ve accepted the contract creation in MetaMask, the contract will be created and the instance appears at the bottom. There you can now call the “greet” method on the contract and see your greeting.
You can also inspect your contract on our block explorer under https://testexplorer.evan.network.
In the next blogpost we will show you, how you can create a customized Dapp for your greeter contract within your evan.network dashboard profile.
If you have any further questions feel free to contact the evan.network team via gitter or over our contact form.