0

enter image description hereError 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)
      }
    }
};

  • What version of Web3 are you using? – Niklas Feurstein Sep 3 at 18:30
  • can u show us the error? – haxerl Sep 4 at 9:29
  • ALERT: Transaction Error. Exception thrown in contract code. – An Le Sep 4 at 14:02
  • I'm just update image with error – An Le Sep 4 at 14:02
  • Web3 version is 1.2.0 – An Le Sep 4 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.