Skip to content

How to get signer of a contract inside a function #15

Answered by banool
0xaptosj asked this question in Questions
Discussion options

You must be logged in to vote

I inadvertently answered this question too somewhere else! Here is my take on it. Similar but different, each answer might suit different users better!

The easiest way to do this would be with an object.

  1. Create an object. Learn more here.
  2. Create an account alongside that object. Learn more here.
  3. Send coins from the object (assuming you have sent coins to it already).

Overall your code to create the object + account would look like this:

entry fun create(caller: &signer) {
  // Create an object.
  let caller_address = signer::address_of(caller);
  let constructor_ref = object::create_object(caller_address);
  let object_address = object::address_from_constructor_ref(&constructor_ref);

  /…

Replies: 3 comments 1 reply

Comment options

0xaptosj
Mar 6, 2024
Maintainer Author

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by 0xaptosj
Comment options

0xaptosj
Mar 7, 2024
Maintainer Author

You must be logged in to vote
1 reply
@0xaptosj
Comment options

0xaptosj Mar 7, 2024
Maintainer Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
move Questions related to the Move Language
2 participants