CryptoFly.us | CRYPTOCURRENCY BITCOIN SHIRTS CLOTHING APPAREL HATS

CRYPTO NEWS

Famed Brit photographer Platon’s NFTs have stars in their eyes

Call a payable contract’s function from another contract via an interface

I have two contracts, they are connected via an interface. When user calls contract1 function, it uses an interface to call contract2 function which updates it’s storage. My problem is that I can get a return value from an event, but data is not saved in that contract2 storage. I get such an error: Transaction::Listen

I have two contracts, they are connected via an interface.

When user calls contract1 function, it uses an interface to call contract2 function which updates it’s storage.

My problem is that I can get a return value from an event, but data is not saved in that contract2 storage.

I get such an error:

Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!

here is a contract1 function which that user calls i.e. buy():

event itemBought(uint256 itemId);  Contract2Interface private contract2Interface;  constructor() public {     contract2Interface = Contract2Interface('contract address'); }  function buy(uint256 itemId) public payable {       // require(some condition);      uint256 itemId = contract2Interface.buy(itemId, msg.sender);     emit itemBought(itemId); } 

here is an interface:

contract contract2Interface {     function buy(uint256 itemId, address owner) public returns(uint256); } 

here is contract2 function:

mapping(bytes32 => uint256) private storage;  function encodeFunc(uint256 itemId, address owner) private pure returns(bytes32) {     return keccak256(abi.encodePacked(itemId, owner)); }  function buy(uint256 itemId, address owner) public returns(uint256) {     storage[encodeFunc(itemId, owner)]++;     return itemId; } 

So here I get that itemId from event, but data is not saved in storage, I don’t get any errors either.

what do you think a problem is ?

Thank you!

Famed Brit photographer Platon’s NFTs have stars in their eyes

Shopping cart
There are no products in the cart!
Continue shopping
0