Install NodeJS and NPM. Windows Users experience fewer failures during installation when NodeJS LTS version 10 is used.
Run npm install
.
Modify the token blueprint (e.g. ./contracts/TanganyERC20.sol) to deploy the token. Make sure the contract file name is referenced correctly in ./migrations/2_deploy_contract.js.
Each deployment environment has a different set of mandatory environment variables. Add the secrets required for the deployment environment to .env
Make sure to provide the PRIVATE_KEY
. Ether by setting a mnemonic (the twelve word phrase), or a 64 character long
hex-decimal string. The associated address will inherit the tokens created by the contract deployment.
Write and run contract tests from ./test
directory. Start up a local development chain running truffle develop
and
run tests with truffle test
.
Following are contracts used for documentation & testing purposes in the Tangany API Suite that were deployed and verified using this repository
-
(2022-08-30) Goerli 0xc06E361F2FBD2ef75dfA2cb3536dC77A4cCFc44c(2019-02-26) Ropsten 0xC32AE45504Ee9482db99CfA21066A59E877Bc0e6 -
(2022-08-30) Goerli 0x317df482Aa62C2866Fa51a9da67E4b1ebAE491d3
(2010-01-21) Mainnet 0x7EAC2E54376fE685Cc10D83bE0e1600e6b5fbA3e -
(2022-08-30) Goerli 0x735fcc036022122082A6f870D6c02F5B3a38668B
(2021-05-11) Ropsten 0x1AF2F9f16ca6A237c6Cd113043532252C9D0f2ba
(2020-10-16) Ropsten 0x6dfC099FD9D1214e37e33Ecb3124dE451b751EbF -
(2022-08-30) Goerli 0xaB20627C1F4afFc6227286DF06a52E7D995D3F23
(2020-10-20) Ropsten 0x6412eFCdD4423f166dcF2475770a6764Bbf6bDB2
(2020-10-06) Ropsten 0xaE3093b6EA3E9dc5a09690A55634504A40E567D3 -
(2022-08-30) Goerli 0x64AC61D4cFC7a38929d5DBA2b0d2b2c0588adDD4
(2020-10-12) Ropsten 0x62f49D4A051a22Cd5573b1197FD3E96F1026346D -
(2022-08-30) Goerli 0xa744274531a5D8578bE6266267659844DEdFa782
(2021-09-10) Ropsten 0x4341f8409dF7EE681Ca3C79250e8e97bD5B32438 -
Test Contract (deprecated):
(2020-07-08) Ropsten 0x61B6a7b2b031Ca7053c3fD28F255AC4B17ecd5a4
Make sure the private key has enough ether on the required network to fund the deployment transactions.
Deploy the smart contract to the desired environment with the provided commands (e.g. npm run deploy:ropsten
). The
address of the deployed contract will be printed to the console output:
C:\www\tangany-test-token>npm run build && npm run deploy:development
> tangany-test-token@1.0.0 prebuild C:\www\tangany-test-token
> rimraf ./build/contracts/*
> tangany-test-token@1.0.0 build C:\www\tangany-test-token
> truffle compile
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\TanganyTestToken.sol
> Compiling openzeppelin-solidity/contracts/token/ERC20/ERC20.sol
> Compiling openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol
> Compiling openzeppelin-solidity\contracts\math\SafeMath.sol
> Compiling openzeppelin-solidity\contracts\token\ERC20\IERC20.sol
> Artifacts written to C:\www\tangany-test-token\build\contracts
> Compiled successfully using:
- solc: 0.5.2+commit.1df8f40c.Emscripten.clang
> tangany-test-token@1.0.0 deploy:development C:\www\tangany-test-token
> truffle migrate --network development
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'development'
> Network id: 5777
> Block gas limit: 6721975
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0x7d67cffd0ca19b0d8065c129510926b30a3ddd2dcdae339ebd4d07b32176a57c
> Blocks: 0 Seconds: 0
> contract address: 0x63A1ca2131B660D0388d15494eBE916d178C9e87
> account: 0xc460f0A72A5860107F2606321401f07549Bb4ddA
> balance: 99.99453676
> gas used: 273162
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.00546324 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.00546324 ETH
2_deploy_contract.js
====================
Deploying 'TanganyTestToken'
----------------------------
> transaction hash: 0xa5283e240886d3955f03af44e1115985e6ea131fe1538f755719f02fb0f3497a
> Blocks: 0 Seconds: 0
> contract address: 0x08D65FFaAA99a54a98AED475f5c9d659eF60CA7b
> account: 0xc460f0A72A5860107F2606321401f07549Bb4ddA
> balance: 99.96902082
> gas used: 1233769
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.02467538 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.02467538 ETH
Summary
=======
> Total deployments: 2
> Final cost: 0.03013862 ETH
In this example the smart contract was deployed to the address 0x08D65FFaAA99a54a98AED475f5c9d659eF60CA7b
on the
Ganache Development network. The address 0xc460f0A72A5860107F2606321401f07549Bb4ddA
gained ownership to the smart
contract and received 10000 tokens.
Required environment variables
- PRIVATE_KEY
npm run build && npm run deploy:development
Required environment variables
- PRIVATE_KEY
- PRIVATE_NETWORK_URL
- PRIVATE_NETWORK_ID
Also make sure to verify the truffle settings for private
match the actual private network (
gas, gasPrice, ...)
npm run build && npm run deploy:private
Required environment variables
- PRIVATE_KEY
- INFURA_KEY
Sign up for a free api key at https://infura.io/dashboard to deploy to public networks.
npm run build && npm run deploy:ropsten
npm run build && npm run deploy:mainnet
In order to verify your smart contract on etherscan.io execute the verification script immediately after the contract is
successfully deployed and pass the contract name as the argument (e.g. npm run verify:ropsten -- TanganyERC20
).
This action supports smart contracts deployed on public Ethereum networks and does require the ETHERSCAN_APIKEY
environment variable to execute. The API key can be generated for free at https://etherscan.io/myapikey. For
troubleshooting use the command option --debug
.
Deploy at your own risk! This software is provided "as-is" without warranty of any kind. Tangany does not take any responsibility for loss of funds caused through use of this repository.
© 2019 Tangany
Imprint • Privacy policy • Newsletter • Twitter • Facebook • LinkedIn • YouTube • Github