Deploying Smart Contracts with Truffle and Ganache

Поділитися
Вставка
  • Опубліковано 8 лют 2025
  • 1. Install Node.js v16 and Truffle globally using --- npm install -g truffle.
    2. Create a directory named meta-coin with --- mkdir meta-coin.
    3. Navigate to the meta-coin directory using --- cd meta-coin.
    4. Unbox the MetaCoin project template with --- truffle unbox metacoin.
    5. Run the metacoin.js test file using --- truffle test ./test/metacoin.js.
    6. Compile the smart contracts with --- truffle compile.
    7. Deploy the contracts to the development network using ---truffle migrate.
    8. Open the Truffle console with --- truffle console.
    9. Get the deployed MetaCoin instance using --- let instance = await MetaCoin.deployed().
    10. Retrieve Ethereum accounts with --- let accounts = await web3.eth.getAccounts().
    11. Check the balance of the first account using --- let balance = await instance.getBalance(accounts[0]).
    12. Convert the balance to a number with --- balance.toNumber().
    13. Transfer 500 MetaCoins to another account with --- instance.sendCoin(accounts[1], 500).
    14. Check the balance of the second account using --- let received = await instance.getBalance(accounts[1]).
    15. Convert the second account balance to a number with --- received.toNumber().
    16. Check and convert the updated balance of the first account using --- let newBalance = await instance.getBalance(accounts[0]) and newBalance.toNumber().
  • Наука та технологія

КОМЕНТАРІ • 7