Migration from Truffle to Etherlime

Migration from Truffle to Etherlime

Install & Initialize Etherlime

npm i -g etherlime

Install the global etherlime to allow you to run etherlime commands.

etherlime init

The command will add to your project structure the following parts:

  • ./contracts/LimeFactory.sol

    • ./deployment/deploy.js

    • ./test/exampleTest.js

Note! These are added just to give you an example. You can remove them.

Write new scripts for deployment using the template provided

  • require etherlime module

  • require the compiled contract from ./build folder not the

    contract itself

with Truffle :

with Etherlime :

  • set the deployer and then deploy the contract

Local deployment with Etherlime :

Find more examples for deployment here.

Modify tests

In order to modify the tests from Truffle to Etherlime, slight changes are needed to be done:

with Truffle :

with Etherlime :

  • **in case you want to use an address of an account, you must extend

    it to** let owner = accounts[0].signer.address

  • **when a contract’s method is called, the default sender is set to

    accounts[0]. If you want to execute it from another account,

    replace** {from: anotherAccount} object with

    .from(anotherAccount).

with Truffle :

with Etherlime :

  • **when you need to execute payable function, pass the value as an

    object** contract.somePayableFunction(arg1, arg2, {value: 100})

  • don't use “.call” when calling view functions.

  • to timeTravel - replace web3 increaseTime with global options

    utils.timeTravel(provider, seconds)

Assertions and available utils

For more convenience Etherlime provides some additional assertions and global utils object:

assert it is an address :

assert a function revert :

test an event

with Truffle:

with Etherlime

Find more test examples here.

Final steps:

  • delete ./migrations folder

  • delete truffle.js/truffle-config.js file

  • delete truffle from package.json

  • delete node_modules

  • run npm install

  • open a fresh terminal tab and enter etherlime ganache

  • run etherlime test

Last updated

Was this helpful?