Blog
Why is etherlime needed?

Why is etherlime needed?

Tech Talks

By

Dimitar Bogdanov

September 2, 2018

4 Min Read

etherlime update: 1st of August 2018

The update includes:

  • etherlime compile — integrated compilation process allowing you to compile your solidity smart contracts. You can now easily enabled/disable optimiser through specifying how many runs of optimisation to perform.
  • etherlime test — integrated unit testing process allowing you to unit test your smart contract. Does not require you to use web3. Also allows you to use the accounts from etherlime ganache and allows to use the etherlime deployment API

At the current state of ethereum smart contract development there are very few alternatives to truffle as a framework. Despite truffle being a good tool, the more you use it the more you find the little hiccups and hurdles that frustrate or stop you from being efficient.

Most of them are due to the underlying web3.js that sometimes, mainly due to legacy reasons, tends to be unstable. Much like ethers.js has grown to be the major alternative to web3.js, etherlime strives to be what truffle is to ethers.js — framework for development and deployment based on this library.

The first obstacle we are about to tackle is deployment of smart contracts and allowing the developers to write their own deployment scripts that are not constrained to just the deployment transactions, but also allow them to use the newly deployed contracts right away as part of the initialisation sequence (this is the main point where truffle struggles as an efficient deployment tool). Inevitably we are going to move to compilation and unit testing too, but we like to move step by step and deliver constant frequent improvements.

Milestones:

Being able to deploy compiled contracts (compiled in the truffle format) on local and infura nodes ←We are here
[Not Ready]Being able to compile contracts to the desired formats for deployment
[Not Ready]Being able to run unit tests on the compiled contracts

Installing

npm install etherlime

Deploying

etherlime exposes the following deployers:

InfuraPrivateKeyDeployer(privateKey, network, apiKey, defaultOverrides) – given private key to the deployment wallet, the network (as found in ethers.providers.networks), your infura API key and default deployment settings for gasPrice and gasLimit it exposes you a deployer object.
JSONRPCDeployer(privateKey, nodeUrl, defaultOverrides) – given private key to the deployment wallet, the url to the node you are trying to connect (local or remote) and default deployment settings for gasPrice and gasLimit it exposes you a deployer object.

Speach Bubble IllustrationGlow Blog Banner

All deployers share the same base functionality:

Deployer functionality

The main functionality the deployer exposes is (obviously) the ability to deploy compiled contract.

This is achieved through the deploy(contract) function. As mentioned before, the contract is descriptor object that needs to have atleast the following three fields:

contractName – the name of the contract
abi – the abi interface of the contract
bytecode – the compiled bytecode

All of these you can get by compiling with Truffle. We will soon expose you a way to do this through etherlime.

const etherlime = require('etherlime');

const TestContract = require('./TestContract.json');

const defaultConfigs = {
gasPrice: 20000000000,
gasLimit: 4700000
}

const deployer = new etherlime.InfuraPrivateKeyDeployer('Your Private Key Goes Here', 'ropsten', 'Your Infura API Key', defaultConfigs);

const runDeployment = async () => {

const result = await deployer.deploy(TestContract, '0xda8a06f1c910cab18ad187be1faa2b8606c2ec86', 1539426974);
}

runDeployment();

Speach Bubble Illustration
Contact Us
Glow Blog Banner

Deployed Contract Wrapper

One of the advancements of the etherlime is the result of the deployment — the DeployedContractWrapper

The DeployedContractWrapper is a powerful object that provides you with ethers.Contract amongst other functionalities. This allows you to start using your deployed contract right away as part of your deployment sequence (f.e. you can call initialization methods)

In addition it exposes you verboseWaitForTransaction(transactionHash, transactionLabel) function. This function can be used to wait for transaction to be mined while giving you verbose output of the state. In addition it allows you to specify a label for the transaction you are waiting for, so that you can get a better understanding of what transaction is being waited for. This comes in handy when deployment scripts start to grow.

const contractWrapper = await deployer.deploy(ICOTokenContract);
const transferTransaction = await contractWrapper.contract.transferOwnership(randomAddress);
const result = await contractWrapper.verboseWaitForTransaction(transferTransaction.hash, 'Transfer Ownership');

Working with previously deployed contracts

Sometimes you want to work with already deployed contract. The deployer object allows you to wrap such an deployed contract by it’s address and continue using the power of the wrapper object. The function you can use to achieve this is wrapDeployedContract(contract, contractAddress).

Compiling

Not ready. TBD

Testing

Not ready. TBD

License

Completely MIT Licensed. Including ALL dependencies.

Have a project in mind?
Drop us a line.

Or just shoot us a message on Telegram

Select Contact Method
Looking for

Thank you! Your submission has been received!

Oops! Something went wrong while submitting the form.
Mail Box IllustrationCube Illustration 2