Hello Zeppelin folks,
I am working on an art project for which I am writing an ERC721 smart contract. I am using infura endpoint and openzeppelin-solidity: "^2.3.0"
framework to speed up the development.
I am not able to deploy on ropsten. truffle deploy --network ropsten-infura --reset
does not do anything after
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
My truffle-config.js looks like the following:
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider');
// MNEMONIC_PHRASE and INFURA_KEY are mentioned in .env file
const mnemonic = process.env.MNEMONIC_PHRASE;
const infuraKey = process.env.INFURA_KEY;
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
},
"ropsten-infura": {
provider: () => new HDWalletProvider(mnemonic, 'https://ropsten.infura.io/v3/' + infuraKey, 0),
network_id: 3,
gas: 5500000,
gasPrice: 100000000000,
timeoutBlocks: 200,
},
mocha: {}
compilers: {
solc: {
version: "0.5.2",
}
}
}
I feels like problem lies in the truffle-config.js file. I am just not able to figure it out. This is my first deployment using truffle. I have deployed before but it was a plane smart contract and i used parity interface.
Help is very appreciated as the deadline to finish this near.
Hi @shubhamy2015
Do you have a migration file in the migrations directory to deploy your ERC721?
e.g. 2_deploy_token.js
var MyContract = artifacts.require("MyContract");
module.exports = function(deployer) {
// deployment steps
deployer.deploy(MyContract);
};
See Truffle documentation on running migrations:
Yes.
I have a file 2_erc721_migration.js
in migrations folder.
const ToTERC721 = artifacts.require("ToTContract");
module.exports = function(deployer) {
deployer.deploy(ToTERC721);
};
ToTERC721.sol
is there in the contracts folder.
pragma solidity >=0.4.21 <0.6.0;
import "../node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";
import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../node_modules/openzeppelin-solidity/contracts/utils/Address.sol";
import "../node_modules/openzeppelin-solidity/contracts/introspection/ERC165.sol";
/**
* @title VoV Non-Fungible Token implementation
* @dev see https://eips.ethereum.org/EIPS/eip-721
*/
contract ToTContract is ERC721 {
...
...
...
...
}
I am successfully able to deploy on Ganache and test it there as well.
1 Like
Hi @shubhamy2015 is your project opensource so that I can attempt to reproduce?
Otherwise I will attempt to replicate myself with the code that you have provided so far.
shubhamy2015:
INFURA_KEY
I am guessing the INFURA_KEY is technically the PROJECT ID
from Infura Dashboard. Am I correct?
Also please check the screenshot. I am leaving those settings untouched. Is that OK too?
1 Like
No, not yet. It’s university project and we have no license yet.
Yes @shubhamy2015 you use the PROJECT ID
as your INFURA_KEY
.
It should be fine to leave the Infura security settings as is.
Please provide your email ID. I will share it with you. At this stage, the solution is more important. Are you on any chat medium? Slack, Discord or telegram? It will make things faster.
1 Like
You can send me a direct message on the forum and I can have a look.
Hi @shubhamy2015
I deployed the following to Ropsten ok using truffle deploy --network ropsten-infura --reset
I put my code on GitHub too. (I added a mint)
I am using truffle version
Truffle v5.0.2 (core: 5.0.2)
I had to add some commas and braces to your truffle-config.js
(assume you cut it down).
I suspect your .env file might be the issue
.env
INFURA_KEY="ENTER YOUR INFURA PROJECT ID HERE"
MNEMONIC_PHRASE="ENTER YOUR 12 WORD SEED PHRASE HERE"
Smart Contract
pragma solidity >=0.4.21 <0.6.0;
import "../node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";
import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../node_modules/openzeppelin-solidity/contracts/utils/Address.sol";
import "../node_modules/openzeppelin-solidity/contracts/introspection/ERC165.sol";
/**
* @title VoV Non-Fungible Token implementation
* @dev see https://eips.ethereum.org/EIPS/eip-721
*/
contract ToTContract is ERC721 {
constructor() public {
_mint(msg.sender, 1);
}
}
2_deploy_token.js
const ToTERC721 = artifacts.require("ToTContract");
module.exports = function(deployer) {
deployer.deploy(ToTERC721);
};
truffle-config.js
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider');
// MNEMONIC_PHRASE and INFURA_KEY are mentioned in .env file
const mnemonic = process.env.MNEMONIC_PHRASE;
const infuraKey = process.env.INFURA_KEY;
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
},
"ropsten-infura": {
provider: () => new HDWalletProvider(mnemonic, 'https://ropsten.infura.io/v3/' + infuraKey, 0),
network_id: 3,
gas: 5500000,
gasPrice: 100000000000,
timeoutBlocks: 200,
},
},
mocha: {},
compilers: {
solc: {
version: "0.5.2",
}
}
}
For future readers the deployment issue was not with @shubhamy2015 code but was a firewall issue and the deployment worked on another computer.
1 Like