0

If we have a case where we have Two smart contracts. Contract A passes value to Contract B. the address of contract A is also passed to contract B in the smart contract. while compiling the contract B how can we access the address of contract A , if we are compiling in javascript.

  • 1
    please add example code to clarify your scenario – Jaime Apr 24 '19 at 10:24
1

Let's assume you have two contract A and contract B. When A calls a function of B, ie b.foo(1234), inside function foo msg.sender will be the address of contract A.

contract A {
    B public b;
    constructor(B _b) public {
        // We initialize b address somehow
        b = _b;
    }
    function bar() public {
        // Make a call to a function foo of contract B
        b.foo(1234);
    }
}

contract B {
    function foo(uint value) public {
        // Inside foo we have:
        // * msg.sender is address of A
        // * value is 1234
    }
}

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