The question about signature

Hello old fellow iron.

When I write the smart contract, I want to complete the function of domain name transfer, but I found that the following methods need to be passed in for signature. How can I call them? Again, I ask you to help me answer the following questions?
If you can, please help write the sample code

payable contract Test =

   payable stateful entrypoint aensTransfer(address : address)  =
       AENS.transfer(Call.caller, address, ?????, ??????)

This is how the document describes it

transfer

AENS.transfer(owner : address, new_owner : address, name_hash : hash, <signature : signature>) : unit

Transfers name to the new owner.

The signature should be over owner address + name_hash + Contract.address using the private key of the owner account for signing.

indent preformatted text by 4 spaces

So owner should be 32 bytes, name_hash should be 32 bytes and contract address should also be 32 bytes. I.e. you got 32 + 32 + 32 = 96 bytes that should be signed using the private key of the owner account.

Let’s imagine you got the signature (which is also 32 bytes, btw) in a variable named s then you call AENS.transfer like this:

AENS.transfer(caller, address, name_hash, signature = s)

And if I have a list, how do I know its size and loop it?

I have a map. How can I get key value circularly?

Thank you for your reply!
Can I have a simple demo to help me go on? I don’t know what methods should signature call?

And if I have a list, how do I know its size and loop it?

I have a map. How can I get key value circularly?

If you want to use a BlockChain I think it would be a good idea to learn how to sign something :slight_smile:

Note: you shouldn’t do this signature inside the contract obviously, since the transaction is visible to everyone.

1 Like

This question and several similar questions have been answered before. I suggest you try to write some code. And once you get properly stuck on something concrete first search properly for the answer, then ask a concrete question.

1 Like

Do you mean that? If I call the smart contract with golang’s SDK, will I pass the signature in through parameters?

Yes, the signature (that allows the contract to act on owner's behalf) has to be computed outside of the contract.

1 Like

OK, thank you for your answer and have a good day