Signer

signer is a built-in Move resource type. A signer is one kind of capabilities that allows the holder to act on behalf of a particular address.

We use signer to represent the address and the permission of the address.


struct signer has drop { a: address }

In transaction, sender is represented by a signer. The Aptos Move VM will translates the identity of the account that signed the transaction into a signer in a Move module entry point.


public fun withdraw(account: &signer, amount:u64): Coin acquires Coin {
let balance = &mut borrow_global_mut<Coin>(Signer::address_of(account)).amount;
*balance = *balance - amount;
Coin { amount }
}

When a signer is not specified in a function, for example, the below deposit function, then no signer-based access controls will be provided for this function:


public fun deposit(account: address, coin: Coin) acquires Coin {
let balance = &mut borrow_global_mut<Coin>(account).amount;
*balance = *balance + coin.amount;
Coin { amount: _ } = coin;
}