deploy_test_token.js 901 B

12345678910111213141516171819202122232425262728293031323334
  1. // run this script with truffle exec
  2. const TokenImplementation = artifacts.require("TokenImplementation")
  3. module.exports = async function(callback) {
  4. const accounts = await web3.eth.getAccounts();
  5. // deploy token contract
  6. const tokenAddress = (await TokenImplementation.new()).address;
  7. const token = new web3.eth.Contract(TokenImplementation.abi, tokenAddress);
  8. console.log("Token deployed at: "+tokenAddress);
  9. // initialize token contract
  10. await token.methods.initialize(
  11. "Test Token",
  12. "TKN",
  13. "18", // decimals
  14. accounts[0], // owner
  15. "0",
  16. "0x00000000000000000000000000000000"
  17. ).send({
  18. from:accounts[0],
  19. gas:1000000
  20. });
  21. // mint 1000 units
  22. await token.methods.mint(accounts[0], "1000000000000000000000").send({
  23. from:accounts[0],
  24. gas:1000000
  25. });
  26. callback();
  27. }