I'm currently designing a smart contract, where I'd basically like to incorporate a "coupon" like relationship between two different coins. Bob can send the smart contract CoinA, and receive CoinB as a result, but only if he also has a proportionate amount of CoinC in the same wallet.

The logic I'm imagining looks like this in psuedo code, I'm just wondering if checking the value of CoinC in the sending wallet is achievable:

if (recievedTransaction.CoinA === sendingAddress.CoinC) {
    return CoinB
else {
    return recievedTransaction.CoinA 

Or if not, I guess as a 2nd best solution the smart contract can receive both tokens as separate transactions, and decide the return value based on if those values match up or a certain amount of time runs out?

1 Answer 1


Yes, if the contract that's doing the checking knows the contract address of the other token it's supposed to check and the address of the account it wants to check, it can do something like:

uint256 other_coin_balance = MetaCoin(other_coin_address).balanceOf(user_address);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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