Polygon
Wallet Structure
The semi-custodial wallet of Polygon has the following structure.
- Main Address
- Fee Address
- Child Address
TIP
The fee address is used to recharge the child address with the fees (MATIC) if necessary.
Child Address
Generates child addresses by calling the Generate Child Address API. Generally, one child address is given to each end user. Generated child addresses can be checked from [Child Address Information] from the console or by calling the Access Child Address List API.
Response example
[
{
"address": "0x236c41418f0320DC7233C8c9dC99EEa5930341D9",
"name": "test polygon address"
}
]
Deposit
Deposit Status
When an asset from the outside arrives at the main or a child address, Octet recognizes it as a deposit. However, the deposit is not finalized even if the deposit transaction is included in the blocks. Additional blocks must be generated to finalize(FINALIZED
) the transaction to ensure the integrity of the transaction. When an asset is sent to a main or a child address but has not arrived, that transaction is not recognized. Therefore, there is no FAILED
status for the deposit transaction.
Status name | Description |
---|---|
UNFINALIZED | Deposit transaction is included in the blocks |
FINALIZED | Deposit transaction is included in the blocks and the next block is generated |
The number of blocks required to finalize the deposit is different depending on the network. Both testnet and mainnet require additional 20 blocks to finalize the transaction.
Testnet | Mainnet |
---|---|
20 block (about 100s) | 20 block (about 40s) |
Deposit Confirmation
1. Checking from the Console
You can check the deposit status from [Transaction History] on the console. UNFINALIZED
deposits are displayed as ‘Processing’, and FINALIZED
deposits are displayed as ‘Completed’.
2. Checking with Webhooks
When a deposit is finalized to a main or a child address, a deposit webhook will be sent. You can check the deposit status from the received webhook. For more information about how to use webhooks and their data structure, check the 'Webhook' page.
Withdrawal
Withdrawal Process
Semi-custodial wallet withdraws assets from the main and child addresses to the outside. In this case, gathering fees will be deducted from the address to be withdrawn. For example, when withdrawing from ‘child address A’, a fee will be deducted from ‘child address A’. Therefore, the address to be withdrawn should have assets (MATIC) to pay the fee. Withdrawal will not proceed if the withdrawal fee is insufficient.
- Request withdrawal.
- Generate transaction.
- Calculates the optimal fees and propagates the transactions.
- Withdrawal is completed when the transactions are confirmed in the blocks.
Withdrawal Status
Unlike a deposit, a withdrawal is finalized(FINALIZED
) at the moment when the transaction is included in the blocks.
Status name | Description |
---|---|
AWAITING_DECISION | Awaiting withdrawal approval |
REJECTED | Withdrawal is denied |
AWAITING_WITHDRAWAL | Approved and awaiting withdrawal |
PENDING | Withdrawal transaction is generated |
FINALIZED | Withdrawal transaction is included in the blocks |
FAILED | Withdrawal transaction failed |
Withdraw
You can request a withdrawal from the main or child address to the outside by calling the Request Withdrawal API. The uuid
value will be returned when the withdrawal request is successful. The value can be used to access the withdrawal process.
Response example
{
"uuid": "18012e3f-07f3-45ec-862b-f020c0ca935a"
}
Withdrawal Confirmation
1. Checking from the Console
You can check the withdrawal status from [Transaction History] on the console. AWAITING_WITHDRAWAL
or PENDING
withdrawals are displayed as ‘Processing’, and FINALIZED
withdrawals are displayed as ‘Completed’.
2. Checking with API
You can check the progress of a specific withdrawal transaction by calling the Access Withdrawal Transaction Information API.
Response example
{
"idx": 490,
"uuid": "07efdcb2-b3fd-4fe7-bf47-c0b460b289e3",
"fromAddress": "0x71b5De2970A32eEf6362AE7Bc3B73103b4392bB0",
"toAddress": "0x295909dC67B76f936BD4119aDd877088602cCaD3",
"amount": "2.00000000000000000000",
"memo": null,
"requestId": "25",
"type": "API",
"description": "",
"requiredApprovalCount": 1,
"useApiAutoApproval": true,
"status": "SENT",
"createdDate": "2022-01-25T09:25:02.383Z",
"modifiedDate": "2022-01-25T09:25:10.000Z",
"rejectedDate": null
}
3. Checking with Webhooks
When the withdrawal from the main address is finished, a withdrawal webhook will be sent. You can check the withdrawal status from the webhook. For more information about how to use webhooks and their data structure, check the Webhook page.
Balance Access Criteria
You can check the balance of the asset stored in a specific address by calling the Access Address Balance API. The accessed balances are specified into total balances and liquid balances.
- Total balance is all assets with a confirmation of 1 or above.
- Liquid balance is assets that can be withdrawn in each address.
Fees
Estimated Fees
Estimated fees are calculated by multiplying the gas limit and the gas price.
Estimated Fees = Gas Limit x Gas Price
- Gas Limit is the maximum gas usage. Octet sets MATIC gas limit to 21,000, and the gas limit for tokens is set to 100,000 since it varies depending on how the tokens are implemented. The actual gas usage could be less than that, and the fees are charged for the actual gas usage.
- Max Fee Per Gas is the maximum value of the fee per gas. You can access the value in real-time by calling the Fee/Gas API. Actual fee per gas could be less than that.
Transaction Fees
Transaction Fees are calculated by multiplying the gas usage and the gas price.
Transaction Fees = Usage by Txn x Gas Price
- Gas Price includes the fee paid to the miner, Max Priority Fee Per Gas. Octet sets the value to 1 Gwei in testnet, 35 Gwei in mainnet.
Faucet
In the case of the testnet, you must obtain a testing MATIC from the faucet website and deposit it. When an actual MATIC is deposited in the testnet, it will not be recognized.
Updated about 1 year ago