Starknet 백서

Starknet

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 73쪽 중 60쪽

ingEvents.sol) * Event: [`LogMessageToL2`](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/solidity/IStarknetMessagingEvents.sol#L9) *** ### `MessageToL2Canceled` #### Description This event is emitted when an L1 to L2 message is canceled by the [`cancelL1ToL2Message`](#cancelL1ToL2Message) function. #### Event attributes | | | | - | - | | `address indexed fromAddress` | The address of the sender on L1. | | `uint256 indexed toAddress` | The address of the receiver on L2. | | `uint256 indexed selector` | The function, in the recipient L2 contract, that the message called. | | `uint256[] payload` | The payload of the canceled message. | | `uint256 nonce` | The nonce of the canceled message. | #### Event definition * Contract: [`IStarknetMessagingEvents`](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/solidity/IStarknetMessagingEvents.sol) * Event: [`MessageToL2Canceled`](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/solidity/IStarknetMessagingEvents.sol#L44) *** ### `MessageToL2CancellationStarted` #### Description This event is emitted when the cancellation of an L1 to L2 message is started by the [`startL1ToL2MessageCancellation`](#startL1ToL2MessageCancellation) function. #### Event attributes | | | | - | - | | `address indexed fromAddress` | The address of the sender on L1. | | `uint256 indexed toAddress` | The address of the receiver on L2. | | `uint256 indexed selector` | The function, in the recipient L2 contract, that the message called. | | `uint256[] payload` | The payload of the message to be canceled. | | `uint256 nonce` | The nonce of the message to be canceled. | #### Event definition * Contract: [`IStarknetMessagingEvents`](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/solidity/IStarknetMessagingEvents.sol) * Event: [`MessageToL2CancellationStarted`](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/solidity/IStarknetMessagingEvents.sol#L35) # StarkGate functions and events Source: https://docs.starknet.io/learn/cheatsheets/starkgate-reference ## L1 functions and events ### `deposit` #### Description Deposits the specified amount of an ERC-20 token to the L1 StarkGate bridge contract. The deposit function does the following: * Transfers the funds from the caller's account to the Starknet bridge contract * Emits the `Deposit` event with the sender's address on L1, the recipient's address on L2, and the amount #### Visibility `external` #### State Mutability `payable` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 l2Recipient` | The L2 address of the recipient. | #### Returns None. #### Emitted event `Deposit` **Event attributes** | | | | - | - | | `address indexed sender` | The L1 address of the account that sent the deposit. | | `address indexed token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 indexed l2Recipient` | The L2 address of the recipient. The L2 address of the recipient. | | `uint256 nonce` | The nonce for the L1 transaction. | | `uint256 fee` | The Starknet fee sent with the transaction. | #### Function and event definitions * Contract: [`StarknetTokenBridge.sol`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol) * Function: [`deposit`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L284) * Event: [`Deposit`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L65) *** ### `depositCancelRequest` #### Description Sends a request to StarkGate to cancel a deposit. You can send a cancellation request if the funds you transfer from L1 to L2 do not appear on L2 within a reasonable amount of time. In order to guard against an attack on Starknet, it takes approximately five days to cancel a deposit. When StarkGate receives the cancellation request, a counter begins. When exactly five days have passed, and the funds still do not appear on L2, you can reclaim the deposit using the [`depositReclaim`](#depositReclaim) function. The `depositReclaim` function can only be used once for any deposit cancellation request. #### Visibility `external` #### State Mutability `nonpayable` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 l2Recipient` | The L2 address of the recipient. | | `uint256 nonce` | The nonce of the deposit. | #### Returns None. #### Emitted event `DepositCancelRequest` **Event attributes** | | | | - | - | | `address indexed sender` | The L1 address of the account that sent the deposit. | | `address indexed token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 indexed l2Recipient` | The L2 address of the recipient. The L2 address of the recipient. | | `uint256 nonce` | The nonce of the deposit. | #### Function and event definitions * Contract: [`StarknetTokenBridge.sol`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol) * Function: [`depositCancelRequest`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L515) * Event: [`DepositCancelRequest`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L73) *** ### `depositReclaim` #### Description Reclaims a deposit after a five day period has passed from the time that StarkGate received a deposit cancellation request from the `depositCancelRequest` function. #### Visibility `external` #### State Mutability `nonpayable` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 l2Recipient` | The L2 address of the recipient. | | `uint256 nonce` | The nonce of the deposit. | #### Returns None. #### Emitted event `DepositReclaimed` **Event attributes** | | | | - | - | | `address indexed sender` | The L1 address of the account that sent the deposit. | | `address indexed token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 indexed l2Recipient` | The L2 address of the recipient. The L2 address of the recipient. | | `uint256 nonce` | The nonce of the deposit. | #### Function and event definitions * Contract: `StarknetTokenBridge.sol` * Function: [`depositReclaim`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L588) * Event: [`DepositReclaimed`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L80) #### See also * [`depositCancelRequest`](#depositCancelRequest) *** ### `depositWithMessage` #### Description Similar to [`deposit`](#deposit), with a message attached. With this function, a deposit transaction can trigger subsequent actions. For example, you can deposit funds and include a message to transfer those funds to another address. `depositWithMessage` lets you execute these two separate transactions with a single user action. After depositing to another recipient, the L1 handler in `token_bridge.cairo` calls the `on_receive` function in the contract of the recipient. If `on_receive` returns `true`, then the `on_receive` function succeeded. If it returns `false`, or if it doesn't return any value because the `on_receive` function is not implemented in the recipient contract, the operation fails and the transaction is reverted. #### Visibility `external` #### State Mutability `payable` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 l2Recipient` | The L2 address of the recipient. | | `uint256[] calldata message` | The message attached to the deposit. | #### Returns None. #### Emitted event `DepositWithMessage` **Event attributes** | | | | - | - | | `address indexed sender` | The L1 address of the account that sent the deposit. | | `address indexed token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 indexed l2Recipient` | The L2 address of the recipient. The L2 address of the recipient. | | `uint256[] message` | The message attached to the deposit. | | `uint256 nonce` | The nonce for the L1 transaction. | | `uint256 fee` | The Starknet fee sent with the transaction. | #### Function and event definitions * Contract: [`StarknetTokenBridge.sol`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol) * Function: [`depositWithMessage`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L255) * Event: [`DepositWithMessage`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L37) *** ### `depositWithMessageCancelRequest` #### Description Sends a request to StarkGate to cancel a deposit sent with `depositWithMessage`. Similar to `depositCancelRequest`. #### Visibility `external` #### State Mutability `nonpayable` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 l2Recipient` | The L2 address of the recipient. | | `uint256[] calldata message` | The message attached to the deposit. | | `uint256 nonce` | The nonce of the deposit. | #### Returns None. #### Emitted event `DepositWithMessageCancelRequest` **Event attributes** | | | | - | - | | `address indexed sender` | The L1 address of the account that sent the deposit. | | `address indexed token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 indexed l2Recipient` | The L2 address of the recipient. The L2 address of the recipient. | | `uint256[] message` | The message attached to the deposit. | | `uint256 nonce` | The nonce for the L1 transaction. | #### Function and event definitions * Contract: [`StarknetTokenBridge.sol`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol) * Function: [`depositWithMessageCancelRequest`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L534) * Event: [`DepositWithMessageCancelRequest`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L46) #### See also * [`depositWithMessage`](#depositWithMessage) * [`depositCancelRequest`](#depositCancelRequest) *** ### `depositWithMessageReclaim` #### Description Reclaims a deposit sent with a message after a five day period has passed from the time that StarkGate received a deposit cancellation request from the `depositWithMessageCancelRequest` function. #### Visibility `external` #### State Mutability `nonpayable` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 l2Recipient` | The L2 address of the recipient. | | `uint256 nonce` | The nonce of the deposit. | #### Returns None. #### Emitted event `DepositWithMessageReclaimed` **Event attributes** | | | | - | - | | `address indexed sender` | The L1 address of the account that sent the deposit. | | `address indexed token` | The address of the contract for the desired token. | | `uint256 amount` | The amount of the deposit. | | `uint256 indexed l2Recipient` | The L2 address of the recipient. The L2 address of the recipient. | | `uint256[] message` | The message attached to the deposit. | | `uint256 nonce` | The nonce for the L1 transaction. | #### Function and event definitions * Contract: [`StarknetTokenBridge.sol`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol) * Function: [`depositWithMessageReclaim`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L564) * Event: [`DepositWithMessageReclaimed`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L54) #### See also * [`depositCancelRequest`](#depositCancelRequest) * [`depositReclaim`](#depositReclaim) * [`depositWithMessageCancelRequest`](#depositWithMessageCancelRequest) *** ### `enrollTokenBridge` #### Description Creates a Starknet bridge for the specified ERC-20 token contract address in the multi-token bridge contracts and adds the token to the StarkGate Registry. Does not work for any ERC-20 token bridge's contract address that is already in the registry. Enrolling a new bridge creates a new ERC-20 contract on L2. You can see the class hash for this contract using [`get_erc20_class_hash`](#get_erc20_class_hash). <Note> Enrolling a new bridge does not add it to the StarkGate GUI. You can use a block explorer to use the newly created bridge. </Note> #### Visibility `external` #### State Mutability `payable` The message payload needs to include funds to cover the Starknet (L2) fee for executing this transaction. You can include this payload using a standard wrapper such as web3.js. #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired ERC-20 token. | #### Returns None. #### Emitted event `TokenEnrollmentInitiated` #### Function and event definition * Function: [`enrollTokenBridge`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarkgateManager.sol#L132) in `StarkgateManager.sol` * Event: [`TokenEnrollmentInitiated`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L34) in `StarknetTokenBridge.sol` *** ### `estimateDepositFeeWei` #### Description Returns an estimate of the fee, in Wei, for depositing funds to the L1 StarkGate bridge contract. #### Visibility `external` #### State Mutability `view` #### Parameters None. #### Returns | | | | - | - | | `uint256` | An estimate of the fee, in Wei, for depositing funds to the L1 StarkGate bridge contract. | #### Emitted event None. #### Function definition [`estimateDepositFeeWei`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L142C28-L142C28) in `StarknetTokenBridge.sol` #### Additional resources * [`deposit`](#deposit) * [`depositWithMessage`](#depositWithMessage) *** ### `estimateEnrollmentFeeWei` #### Description Returns an estimate of the fee, in Wei, for creating and registering a new bridge using the `enrollTokenBridge` function. #### Visibility `external` #### State Mutability `view` #### Parameters None. #### Returns | | | | - | - | | `uint256` | An estimate of the fee, in Wei, for creating and registering a new bridge. | #### Emitted event None. #### Function definition [`estimateEnrollmentFeeWei`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L146) in `StarknetTokenBridge.sol` #### Additional resource * [`enrollTokenBridge`](#enrollTokenBridge) *** ### `getBridge` #### Description Returns the address of the bridge for the specified token, or a value indicating if the bridge does not exist, is blocked, or is deactivated. #### Visibility `external` #### State Mutability `view` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired ERC-20 token. | #### Returns | | | | - | - | | `address address` | The address of the bridge for the specified token. | | `Address(0)` | The bridge does not exist. | | `Address(1)` | The bridge is blocked or deactivated. | #### Emitted event None. #### Function definition [`getBridge`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/IStarkgateRegistry.sol#L8) in `IStarkgateRegistry.sol` *** ### `getRegistry` #### Description Returns the address of the StarkGate Registry contract. Only the Manager uses this function. #### Visibility `external` #### State Mutability `view` #### Parameters None #### Returns | | | | - | - | | `address` | The address of the Registry contract. | #### Emitted event None. #### Function definition [`getRegistry`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarkgateManager.sol#L24) in `StarkgateManager.sol` *** ### `getStatus` #### Description Returns the status of a token in StarkGate. #### Visibility `external` #### State Mutability `view` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired ERC-20 token. | #### Returns | | | | - | - | | `TokenStatus` | One of the following values:<br /><br />0 : Unknown. The bridge does not recognize the token.<br /><br />1 : Pending. The token has been enrolled to StarkGate, but the deploy transaction has not yet successfully completed. You can deposit funds.<br /><br />2 : Active. The deploy transaction for this token has completed successfully and StarkGate recognizes the token.<br /><br />3 : Deactivated. The token has been removed from StarkGate. You cannot deposit funds. | #### Emitted event None. #### Function definition [`getStatus`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L198C23-L198C23) in `StarknetTokenBridge.sol` *** ### `getWithdrawalBridges` #### Description Retrieves a list of all bridge addresses that have ever facilitated withdrawals for the specified token. In a case where an inactive bridge for a specific token might still have funds locked, you can use this function to identify all bridges that ever serviced that token. If you used a bridge for a given token that subsequently was replaced with a new or updated bridge, but you still have funds locked on the first bridge, you might not know the address of the old bridge. #### Visibility `external` #### State Mutability `view` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | #### Returns | | | | - | - | | `address[] memory bridges` | An array of addresses of all bridges that ever serviced `token`. | #### Emitted event None. #### Function definition [`getWithdrawalBridges`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarkgateRegistry.sol#L110) in `StarkgateRegistry.sol`. *** ### `identify` #### Description Returns the name and version of the `StarknetTokenBridge.sol` contract. #### Visibility `external` #### State Mutability `pure` #### Parameters None. #### Returns | | | | - | - | | `string memory` | The name and version of the `StarknetTokenBridge.sol` contract. | #### Emitted event None. #### Function definition [`identify`](https://github.com/starknet-io/starkgate-contracts/tree/v2.0.1/src/solidity/StarknetTokenBridge.sol#L92) in `StarknetTokenBridge.sol` *** ### `isServicingToken` #### Description Checks whether the calling contract is currently providing a service for the specified token. #### Visibility `external` #### State Mutability `view` #### Parameters | | | | - | - | | `address token` | The address of the contract for the desired token. | #### Returns | | | | - | - | | `true` | The calling contract is currently providing a service for the token. | | `false` | The calling contract is not currently providing a service for the token. | #### Emitted event None. #### Function definition [`isSer
프로젝트로 돌아가기