Deploying a smart contract to Ethereum blockchain

These are the steps for deploying a smart contract to Ethereum blockchain with Truffle:

  1. Write a migration script: To deploy your smart contract, you need to write a migration file. Create a new file named migrations/2_deploy_donation.js. Then, we fill this file with the following script:
var Donation = artifacts.require("./Donation.sol");module.exports = function(deployer) {  deployer.deploy(Donation);};

As for the migrations/1_initial_migration.js and contracts/Migrations.sol files, we leave these as they are for now. Truffle needs these files in order to deploy a smart contract.

  1. Launch Ganache (the blockchain for Ethereum development): Now you need to launch Ganache. Assuming you have ...

Get Hands-On Blockchain for Python Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.