5. Using Conflux-Truffle
Use Conflux-Truffle to quickly build a dApp on Conflux Core
Last updated
Was this helpful?
Use Conflux-Truffle to quickly build a dApp on Conflux Core
Last updated
Was this helpful?
Note: Sandbox functionality is only available after logging in to ChainIDE via GitHub.
Open Sandbox
create project
create a empty project
A cfxtruffle project will include these folders:
build
contract compiled stuff(json)
contracts
solidity code
migrations
migration scripts
test
testing file
truffle-config.js
config file
create new contracts, tests, migrations
cfxtruffle create
Helper to create new contracts, migrations and tests
All compiled stuff saved at build
folder.
cfxtruffle now support deploy contract to a remote node, the only work to do is set the privateKeys
in truffle-config.
deploy
is a alias to migrate
, truffle use migration
command run contract deploy and migrate.
Every script in migration folder define a migrate task, if you add a new contract you should add a new migration scripts.
Every truffle project will have a contract called Migration
which used to save the project's last migration number, this contract have two method: last_completed_migration()
, setCompleted(num)
When cfxtruffle deploy run it will get the last deployed number from chain, will only run new added migration tasks.
cfxtruffle also provide a command that enable us interact with a contract convenient.
Truffle comes standard with an automated testing framework (built onto mocha and chai)
Unit test code examples
run tests
develop
build
create project from templates --
The create command will create files in contracts
, migrations
, test
folder. Notice the automated created migration file's name will include timestamp, you need manual change to the correct sequal number. For detail reason check
cfxtruffle deploy
also provide three paramter (--reset, --from, --to) which can control the migration running rule. For detail explanation check
For detail documentation check truffle and . And for the documentation of js-conflux-sdk
find it
This quickstart showed you the basics of the Truffle project lifecycle, but there is much more to learn. Please continue on with the rest of .