Migration from Truffle to Etherlime
Migration from Truffle to Etherlime
Install & Initialize Etherlime
npm i -g etherlimeInstall the global etherlime to allow you to run etherlime commands.
etherlime initThe 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
./migrationsfolderdelete
truffle.js/truffle-config.jsfiledelete
trufflefrompackage.jsondelete
node_modulesrun
npm installopen a fresh terminal tab and enter
etherlime ganacherun
etherlime test
Last updated
Was this helpful?