1

I want to transfer ownership of an already notarized file with a particular address. I am using smart contract and representing ownership by "msg.sender" i.e. selected account in metamask is the owner.

Problem is that I am trying to call smart contract function using a address from the metamask account list that is not currently active but I am only able to fetch the currently selected one in metamask.

Is there any way to access the account not currently selected in metamask and making transaction using it?

  • I'm afraid I don't quite understand what you are asking. You can't send a transaction from an account which you don't own. So what would you like to accomplish exactly? – Lauri Peltonen Nov 21 '18 at 19:22
  • Are you using a smart contract? How is ownership represented in that contract? – Ismael Nov 21 '18 at 20:03
  • @LauriPeltonen i am working with test network and i have added multiple accounts in my metamask, for testing purpose i want to transfer ownership of a notarized file from one account to another. – Dhankhar Nov 22 '18 at 4:09
  • @Ismael yes, i am using smart contract and i am representing ownership by "msg.sender". means selected account in metamask is the owner. account[0] – Dhankhar Nov 22 '18 at 4:10
0

An approach can be to have a mapping from document's hash to owner address.

mapping (bytes32 => address) ownership;

Now to transfer ownership you have to override the old owner with the new one

event NewOwner(bytes32 docId, address newOwner);

function transferOwnership(bytes32 docId, address newOwner) public {
    // Only the owner can transfer ownership
    require(ownership[docId] == msg.sender);
    ownership[docId] = newOwner;
    emit NewOwner(docId, newOwner);
}

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.