class SErc677Contract
Methods
allowance(owner, spender)
Name | Type | Description |
---|---|---|
|
|
The address of the token owner. |
|
|
The address of the spender. |
Returns |
|
The amount of tokens approved for the spender, as a UInt64. Implement allowance functionality to enable approved spending. |
allowance(owner: PublicKey, spender: PublicKey): UInt64;
approveBase(forest)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
approveBase(forest: AccountUpdateForest): Promise<void>;
approveSpend(spender, value)
Name | Type | Description |
---|---|---|
|
|
The address to approve as a spender. |
|
|
The amount of tokens to approve. |
Returns |
|
True if the approval was successful, false otherwise. Approval Implement allowance functionality to enable token approvals. |
approveSpend(spender: PublicKey, value: UInt64): Promise<void>;
balanceOf(owner)
Name | Type | Description |
---|---|---|
|
|
|
Returns |
|
balanceOf(owner: PublicKey | AccountUpdate): Promise<UInt64>;
burn(receiverAddress, amount)
Burns (destroys) existing tokens, reducing the total supply.
This method assumes that authorization checks for burning are handled elsewhere. It directly performs the following steps: 1. Retrieves the current total supply of tokens in circulation. 2. Asserts consistency of the retrieved state value. 3. Calculates the new total supply after burning. 4. Calls the underlying token module to burn the specified tokens. 5. Updates the total token supply in the contract’s state.
Name | Type | Description |
---|---|---|
|
|
The address of the token holder whose tokens will be burned |
|
|
The amount of tokens to burn This method does not explicitly check for authorization to burn tokens. It’s essential to ensure that appropriate authorization mechanisms are in place to prevent unauthorized token burning. |
Returns |
|
burn(receiverAddress: PublicKey, amount: UInt64): Promise<void>;
deploy()
Deploys the contract to the blockchain and configures permissions.
This method sets up proof-based permissions for sensitive actions.
deploy(): Promise<void>;
init()
Initializes the contract after deployment.
This method performs the following steps: 1. Calls the superclass’s init
method to handle any base initialization tasks. 2. Sets the token symbol for the contract. 3. Initializes the total amount of tokens in circulation to zero.
init(): void;
mint(receiverAddress, amount)
Mints new tokens and assigns them to a receiver.
This method assumes that authorization checks for minting are handled elsewhere. It directly performs the following steps: 1. Retrieves the current total supply of tokens in circulation. 2. Asserts consistency of the retrieved state value. 3. Calculates the new total supply after minting. 4. Calls the underlying token module to mint the new tokens. 5. Updates the total token supply in the contract’s state.
Name | Type | Description |
---|---|---|
|
|
The address of the receiver who will receive the newly minted tokens |
|
|
The amount of tokens to mint |
Returns |
|
mint(receiverAddress: PublicKey, amount: UInt64): Promise<void>;
name()
This method adheres to the ERC677 standard for retrieving the token’s name. It converts the stored string name into a CircuitString for compatibility with zkApp operations.
name(): CircuitString;
symbol()
This method adheres to the ERC677 standard for retrieving the token’s symbol. It converts the stored string symbol into a CircuitString for compatibility with zkApp operations.
symbol(): CircuitString;
totalSupply()
This method accesses the totalAmountInCirculation
state variable to provide the current token supply.
totalSupply(): UInt64;
transferAndCall(to, value, data0, data1, data2, data3)
Transfers tokens to a recipient and optionally calls a contract method.
Name | Type | Description |
---|---|---|
|
|
The address of the recipient. |
|
|
The amount of tokens to transfer. |
|
|
The first additional field to be passed to the contract method, if applicable. |
|
|
The second additional field to be passed to the contract method, if applicable. |
|
|
The third additional field to be passed to the contract method, if applicable. |
|
|
The fourth additional field to be passed to the contract method, if applicable. |
Returns |
|
{Bool} - Returns |
transferAndCall(to: PublicKey, value: UInt64, data0: Field, data1: Field, data2: Field, data3: Field): Promise<void>;
transferFrom(from, to, value)
Similar to transfer()
, but allows transferring tokens from a specified address, often for approved spending. Also relies on the zkApp protocol for secure balance checks and emits a Transfer event.
Name | Type | Description |
---|---|---|
|
|
The address to transfer tokens from. |
|
|
The address to transfer tokens to. |
|
|
The amount of tokens to transfer. |
Returns |
|
True if the transfer was successful, false otherwise. Transfer |
transferFrom(from: PublicKey, to: PublicKey, value: UInt64): Promise<void>;