0
  1. My question is what are the limitations of one contract using another contract ?

  2. When I'm using another contract as shown below, What is the another contract storing ? e.g: If contract B calls contract A's function like the example below. i) Is contract A storing the reference that Contract B called it ? or Is it vice versa or that is like a one time call? ii) Ok, After I have called the Contract A's function from Contract B, Can I check the transaction that was made by contract b, Like e.g: Contract B called a payable function of Contract A and I want to see that transaction, So I call another function of A that views(gets) me that transaction's data, Is that possible ?

e.g:

Contract A{/*Some code*/
function myFunc()internal view returns(bool){/*Some Code*/}
}

Contract B{
function someFunc(address AContractsAddress)internal payable {

bool check =  A(AContractsAddress).myfunc();

}

}

1 Answer 1

0

You cannot access on-chain transaction data and events from inside the EVM. What you can access instead, is any data that your contract has stored for its own use, by its functions, when those functions were running.

For example:

contract A { function transact(...) external { myList.push(...); } }

When transact() gets called it saves some data in myList. Later, it can read myList to see what happened before.

off-chain (e.g., in a program that uses an Ethereum node's RPC address to request block data etc), you can decode all the external calls and transactions that occurred on-chain. This is non-trivial, so Ethereum includes a mechanism (called events or logs in Solidity) to "log" data including fields that are "indexed" so that you can more easily extract just the log data matching a given contract address and the "indexed" field values that you want.

For example, ERC20 tokens emit "Transfer(...)" logs on each token transfer.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.