Error when I try to send eth from fontend react to smart contract and from contract I tranfer eth to another address but it error, when I try it in remix then it total work. I user web3js to call func in smart contract and build on ropsten. Please help me!
mapping(bytes32 => ContractModel.Contract) public contractList;
mapping(bytes32 => RealEstateModel.RealEstate) public realestateList;
bytes32[] public contractIndex;
address public ownerContract = 0xb0891aaCEaA2Cfd76c7D5512724ffCf6bA2F857E;
function createContract(bytes32 _id, address _seller, bytes32 _id_realestate, uint256 _rentalPeriod, uint256 _dateCreated) public payable {
uint256 newIndex = contractIndex.length;
contractList[_id].id = _id;
contractList[_id].seller = _seller;
contractList[_id].buyer = msg.sender;
contractList[_id].id_realestate = _id_realestate;
contractList[_id].valueTransaction = msg.value;
contractList[_id].rentalPeriod = _rentalPeriod;
contractList[_id].dateCreated = _dateCreated;
contractList[_id].index = newIndex;
contractIndex.push(_id);
_seller.transfer(msg.value*99/100 + 5);
ownerContract.transfer(msg.value*1/100 - 5);
}
gaiaChainWeb3Instance.createContract(
"0x7465737400000000000000000000000000000000000000000000000000000000",
"0xA78C712d44c1E39E93C7139804727D04701b6f14",
"0x7465737400000000000000000000000000000000000000000000000000000000",
contract.rentalPeriod,
Date.now(),
{
from: coinbase,
value: web3.toWei(30, "ether")
}
Config
const HDWalletProvider = require("truffle-hdwallet-provider");
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
ropsten: {
provider: () => new HDWalletProvider("xxx", "https://ropsten.infura.io/v3/xxx"),
network_id: 3,
gas: 8000000,
chainId: 3,
gasPrice: "0x9184e72a000",
},
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*",
gas: 9000000,
gasPrice: 1000000000,
}
},
compilers: {
solc: {
version: "0.4.24" // ex: "0.4.20". (Default: Truffle's installed solc)
}
}
};
ALERT: Transaction Error. Exception thrown in contract code.