FungibleTokenAdvancedAdmin
Class: FungibleTokenAdvancedAdmin
Properties overview
- adminData: State; ↗
- adminPublicKey: State; ↗
- events: {
updateWhitelist: typeof Whitelist;
}; ↗ - updateWhitelist: typeof Whitelist = Whitelist; ↗
- Overrides: TokenContract.events ↗
- tokenContract: State; ↗
- whitelist: State; ↗
- Overrides: TokenContract.approveBase ↗
- Overrides: TokenContract.deploy ↗
Methods overview
- approveBase() ↗
- canChangeAdmin() ↗
- canChangeVerificationKey() ↗
- canMint() ↗
- canPause() ↗
- canResume() ↗
- deploy() ↗
- updateVerificationKey() ↗
- updateWhitelist() ↗
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:84
A contract that grants permissions for administrative actions on a token.
We separate this out into a dedicated contract. That way, when issuing a token, a user can
specify their own rules for administrative actions, without changing the token contract itself.
The advantage is that third party applications that only use the token in a non-privileged way
can integrate against the unchanged token contract.
Extends
TokenContract
Implements
Constructors
new FungibleTokenAdvancedAdmin()
new FungibleTokenAdvancedAdmin(address: PublicKey, tokenId?: Field): FungibleTokenAdvancedAdmin
Defined in: node_modules/o1js/dist/node/lib/mina/zkapp.d.ts:148
Parameters
address
PublicKey
tokenId?
Field
Returns
Inherited from
TokenContract.constructor
Properties
adminData
adminData: State<Field>;
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:91
adminPublicKey
adminPublicKey: State<PublicKey>;
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:88
events
events: {
updateWhitelist: typeof Whitelist;
};
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:122
A list of event types that can be emitted using this.emitEvent()`.
updateWhitelist
updateWhitelist: typeof Whitelist = Whitelist;
Implementation of
FungibleTokenAdminBase.events
Overrides
TokenContract.events
tokenContract
tokenContract: State<PublicKey>;
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:89
whitelist
whitelist: State<Whitelist>;
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:90
Methods
approveBase()
approveBase(forest: AccountUpdateForest): Promise<void>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:98
Overrides the approveBase method to prevent transfers of tokens.
Parameters
forest
AccountUpdateForest
The account update forest.
Returns
Promise
<void
>
Overrides
TokenContract.approveBase
canChangeAdmin()
canChangeAdmin(_admin: PublicKey): Promise<Bool>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:227
Parameters
_admin
PublicKey
Returns
Promise
<Bool
>
Implementation of
FungibleTokenAdminBase.canChangeAdmin
canChangeVerificationKey()
canChangeVerificationKey(_vk: VerificationKey): Promise<Bool>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:256
Parameters
_vk
VerificationKey
Returns
Promise
<Bool
>
Implementation of
FungibleTokenAdminBase.canChangeVerificationKey
canMint()
canMint(_accountUpdate: AccountUpdate): Promise<Bool>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:145
Parameters
_accountUpdate
AccountUpdate
Returns
Promise
<Bool
>
Implementation of
FungibleTokenAdminBase.canMint
canPause()
canPause(): Promise<Bool>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:233
Returns
Promise
<Bool
>
Implementation of
FungibleTokenAdminBase.canPause
canResume()
canResume(): Promise<Bool>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:239
Returns
Promise
<Bool
>
Implementation of
FungibleTokenAdminBase.canResume
deploy()
deploy(props: FungibleTokenWhitelistedAdminDeployProps): Promise<void>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:102
Deploys a TokenContract.
In addition to base smart contract deployment, this adds two steps:
- set the
access
permission toproofOrSignature()
, to prevent against unauthorized token operations- not doing this would imply that anyone can bypass token contract authorization and simply mint themselves tokens
- require the zkapp account to be new, using the
isNew
precondition.
this guarantees that the access permission is set from the very start of the existence of this account.
creating the zkapp account before deployment would otherwise be a security vulnerability that is too easy to introduce.
Note that because of the isNew
precondition, the zkapp account must not be created prior to calling deploy()
.
If the contract needs to be re-deployed, you can switch off this behaviour by overriding the isNew
precondition:
async deploy() {
await super.deploy();
// DON'T DO THIS ON THE INITIAL DEPLOYMENT!
this.account.isNew.requireNothing();
}
Parameters
props
FungibleTokenWhitelistedAdminDeployProps
Returns
Promise
<void
>
Implementation of
FungibleTokenAdminBase.deploy
Overrides
TokenContract.deploy
updateVerificationKey()
updateVerificationKey(vk: VerificationKey): Promise<void>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:130
Update the verification key.
Note that because we have set the permissions for setting
the verification key to impossibleDuringCurrentVersion()
,
this will only be possible in case of a protocol update that requires an update.
Parameters
vk
VerificationKey
Returns
Promise
<void
>
updateWhitelist()
updateWhitelist(whitelist: Whitelist): Promise<void>
Defined in: packages/token/src/FungibleTokenAdvancedAdmin.ts:244
Parameters
whitelist
Whitelist
Returns
Promise
<void
>
Updated 10 days ago