I tried to deploy my contracts but every time I get this error. The first two contracts were deployed successfully, but the third contract, "PostFactory.sol" is facing this issue in loops. I am using Infura and I am deploying it on the rinkeby test network.
Codes
This is my truffle-config.js file
const path = require("path");
const HDWalletProvider = require("truffle-hdwallet-provider");
const initializedProvider = new HDWalletProvider(
"<SEED_PHRASE>",
"https://rinkeby.infura.io/v3/<INFURA_KEY>",
initializedProvider.engine.start();
module.exports = {
networks:{
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*"
},
rinkeby: {
provider: initializedProvider,
network_id: 4,
skipDryRun: true,
}
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
},
contracts_build_directory: path.join(__dirname, "client/src/contracts")
};
This is the deployment file of migrations.
var UserFactory = artifacts.require("./UserFactory.sol");
var PostFactory = artifacts.require("./PostFactory.sol");
module.exports = function (deployer) {
deployer.deploy(PostFactory, UserFactory.address);
};
This is the smart contract "PostFactory.sol" which is causing this error!
'''
pragma solidity ^0.5.0;
import "./Post.sol";
import "./UserFactory.sol";
import "./OriginalPost.sol";
import "./SharedPost.sol";
contract PostFactory {
//user contract address => user's posts contract addresses
mapping(address => address[]) public posts;
// need userfactory to check if user exits or not before create post
UserFactory private userFactory;
constructor(address user_factory_address)public{
userFactory=UserFactory(user_factory_address);
}
function createPost(address user_contract_address,string memory post_text, string memory imageUrl) public {
require(userFactory.checkUserExists(msg.sender));
require(auth(user_contract_address,msg.sender),"user contract address is not yours");
Post post = new OriginalPost(user_contract_address,post_text,imageUrl);
posts[user_contract_address].push(address(post));
}
function getPostsOfUser(address user_contract_address) public view returns(address[] memory){
return posts[user_contract_address];
}
function sharePost(address user_contract_address,address original_post_address, string memory post_text) public {
require(userFactory.checkUserExists(msg.sender));
require(auth(user_contract_address,msg.sender),"user contract address is not yours");
OriginalPost originalPost = OriginalPost(original_post_address);
originalPost.increamentShares();
Post post = new SharedPost(user_contract_address,original_post_address,post_text);
posts[user_contract_address].push(address(post));
}
function auth(address user_contract_address,address msg_sender) public view returns(bool){
User user = User(user_contract_address);
if(user.isOwner(msg_sender))
return true;
else
return false;
}
}
'''
Enviornment
Node js - 14.17.0
truffle- 5.1.39
npm- 6.14.13