How to deploy a smart contract on a public test network (Rinkeby) using INFURA + TRUFFLE +… (2024)

Infura

Infura is a hosted Ethereum node cluster that lets your users run your application without requiring them to set up their own Ethereum node. With Infura you can:

  • Interact with Ethereum networks like Rinkeby or the Mainnet.
  • Deploy contracts to Ethereum networks.
  • Interact with contracts on Ethereum networks.

Truffle

Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier. You can develop contracts, test them and deploy them to test and production Ethereum networks with the help of Infura and truffle-hdwallet-provider.

truffle-hdwaller-provider

Truffle can sign transactions through the use of its HDWalletProvider. This provider can handle the transaction signing as well as the connection to the Ethereum network.

  1. Register to infura.
How to deploy a smart contract on a public test network (Rinkeby) using INFURA + TRUFFLE +… (2)

2. Create a new project, change the endpoint to Rinkeby and copy the URL of the endpoint for Rinkeby.

How to deploy a smart contract on a public test network (Rinkeby) using INFURA + TRUFFLE +… (3)
How to deploy a smart contract on a public test network (Rinkeby) using INFURA + TRUFFLE +… (4)
How to deploy a smart contract on a public test network (Rinkeby) using INFURA + TRUFFLE +… (5)

3. Install HDWalletProvider

npm install truffle-hdwallet-provider

4. Edit truffle.js to set up the truffle-hdwallet-provider and the connection to the Rinkeby network

var HDWalletProvider = require("truffle-hdwallet-provider");
var mnemonic = "orange apple banana ... ";
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*"
},
rinkeby: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/<INFURA_Access_Token>");
},
network_id: 4,
gas: 4500000,
gasPrice: 10000000000,
}
}
};

Provide a reference to your mnemonic that generates your accounts on metamask.

5. Use an ether faucet to fund the transaction to deploy the contract

Make sure you have enough ether in your account to do the deployment. You can acquire ether on the Rinkeby network through a service known as a faucet like the ones mentioned in this link and using the account that you own.

6. Deploy the contract

Create a file on the migrations folder to add instructions to deploy your contract, in this case called MyNotary. Note that the filename needs to have a prefixed with a number and is suffixed by a description, for example 4_example_migration.js. The numbered prefix is required in order to record whether the migration ran successfully. The suffix is purely for human readability and comprehension.

var MyNotary = artifacts.require(“MyNotary”);
module.exports = function(deployer, network, accounts) {
deployer.deploy(MyNotary,{from: accounts[0]});
};

Compile your project, if not already done:

truffle compile

Deploy to the Rinkeby network

truffle migrate --network rinkeby

If you are having problems deploying the contract because it takes a long time to deploy or because it consumes a lot of funds please add this to the truffle-config.js:

How to deploy a smart contract on a public test network (Rinkeby) using INFURA + TRUFFLE +… (6)

The number of runs (--optimize-runs) specifies roughly how often each opcode of the deployed code will be executed across the life-time of the contract. This means it is a trade-off parameter between code size (deploy cost) and code execution cost (cost after deployment). A “runs” parameter of “1” will produce short but expensive code. In contrast, a larger “runs” parameter will produce longer but more gas efficient code. The maximum value of the parameter is 2**32-1.

link

  • You tested all of your functions in your contract locally with truffle and all of the tests pass successfully.
  • You have the Migrations.sol contract.
  • You have a migrations file for Migrations.sol
  • You have a migrations file for your smart contract.
  • You registered in infura.io and created a new project.
  • You have a truffle.js or truffle-config.js file to configure truffle and deployment.
  • You updated the mnemonic in truffle.js.
  • You have enough funds. If you need funds please try the faucets mentioned in this link.
How to deploy a smart contract on a public test network (Rinkeby) using INFURA + TRUFFLE +… (2024)
Top Articles
Jumbo Loans vs. Conventional Loans: What's the Difference?
Seven Dangers of Home Equity Loans | Benchmark FCU
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Craigslist Motorcycles Jacksonville Florida
Wausau Marketplace
Sam's Club Gas Price Hilliard
Best Transmission Service Margate
King Fields Mortuary
Mens Standard 7 Inch Printed Chappy Swim Trunks, Sardines Peachy
Video shows two planes collide while taxiing at airport | CNN
1-833-955-4522
Kylie And Stassie Kissing: A Deep Dive Into Their Friendship And Moments
Jbf Wichita Falls
Walgreens Alma School And Dynamite
Www Craigslist Madison Wi
Who is Jenny Popach? Everything to Know About The Girl Who Allegedly Broke Into the Hype House With Her Mom
Kentuky Fried Chicken Near Me
Move Relearner Infinite Fusion
Restored Republic June 16 2023
Strange World Showtimes Near Savoy 16
Acurafinancialservices Com Home Page
Intel K vs KF vs F CPUs: What's the Difference?
Missing 2023 Showtimes Near Grand Theatres - Bismarck
James Ingram | Biography, Songs, Hits, & Cause of Death
Loopnet Properties For Sale
Ravens 24X7 Forum
Moonrise Time Tonight Near Me
Khatrimmaza
Wega Kit Filtros Fiat Cronos Argo 1.8 E-torq + Aceite 5w30 5l
Grandstand 13 Fenway
Southern Democrat vs. MAGA Republican: Why NC governor race is a defining contest for 2024
Greencastle Railcam
Compress PDF - quick, online, free
Tamilyogi Ponniyin Selvan
Skip The Games Ventura
Ludvigsen Mortuary Fremont Nebraska
Bismarck Mandan Mugshots
10 games with New Game Plus modes so good you simply have to play them twice
Telugu Moviez Wap Org
Craigslist Tulsa Ok Farm And Garden
Silive Obituary
Engr 2300 Osu
Peace Sign Drawing Reference
Victoria Vesce Playboy
Aloha Kitchen Florence Menu
Plumfund Reviews
Hughie Francis Foley – Marinermath
Puss In Boots: The Last Wish Showtimes Near Valdosta Cinemas
Craigslist Pets Lewiston Idaho
Prologistix Ein Number
Tenichtop
Island Vibes Cafe Exeter Nh
Latest Posts
Article information

Author: Carmelo Roob

Last Updated:

Views: 5441

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.