Skip to content

Latest commit

 

History

History
144 lines (123 loc) · 6.52 KB

File metadata and controls

144 lines (123 loc) · 6.52 KB

polycli ulxly claim asset

Auto-generated documentation.

Table of Contents

Description

Claim a deposit.

polycli ulxly  claim asset [flags]

Usage

This command will connect to the bridge service, generate a proof, and then attempt to claim the deposit on which never network is referred to in the --rpc-url argument. This is the corresponding interface in the bridge contract:

/**
 * @notice Verify merkle proof and withdraw tokens/ether
 * @param smtProofLocalExitRoot Smt proof to proof the leaf against the network exit root
 * @param smtProofRollupExitRoot Smt proof to proof the rollupLocalExitRoot against the rollups exit root
 * @param globalIndex Global index is defined as:
 * | 191 bits |    1 bit     |   32 bits   |     32 bits    |
 * |    0     |  mainnetFlag | rollupIndex | localRootIndex |
 * note that only the rollup index will be used only in case the mainnet flag is 0
 * note that global index do not assert the unused bits to 0.
 * This means that when syncing the events, the globalIndex must be decoded the same way that in the Smart contract
 * to avoid possible synch attacks
 * @param mainnetExitRoot Mainnet exit root
 * @param rollupExitRoot Rollup exit root
 * @param originNetwork Origin network
 * @param originTokenAddress  Origin token address, 0 address is reserved for gas token address. If WETH address is zero, means this gas token is ether, else means is a custom erc20 gas token
 * @param destinationNetwork Network destination
 * @param destinationAddress Address destination
 * @param amount Amount of tokens
 * @param metadata Abi encoded metadata if any, empty otherwise
 */
function claimAsset(
    bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofLocalExitRoot,
    bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata smtProofRollupExitRoot,
    uint256 globalIndex,
    bytes32 mainnetExitRoot,
    bytes32 rollupExitRoot,
    uint32 originNetwork,
    address originTokenAddress,
    uint32 destinationNetwork,
    address destinationAddress,
    uint256 amount,
    bytes calldata metadata
) external ifNotEmergencyState {

Here is a direct link to the source code as well.

In order to claim an asset or a message, you need to know deposit count. Usually this is in the event data of the transaction. Alternatively, you can usually directly attempt to see the pending deposits by querying the bridge API directly. In the case of Cardona, the bridge service is running here: https://bridge-api.cardona.zkevm-rpc.com

curl -s https://bridge-api.cardona.zkevm-rpc.com/bridges/0x3878Cff9d621064d393EEF92bF1e12A944c5ba84 | jq '.'

In the output of the above command, I can see a deposit that looks like this:

{
  "leaf_type": 0,
  "orig_net": 0,
  "orig_addr": "0x0000000000000000000000000000000000000000",
  "amount": "123456",
  "dest_net": 0,
  "dest_addr": "0x3878Cff9d621064d393EEF92bF1e12A944c5ba84",
  "block_num": "9695587",
  "deposit_cnt": 9075,
  "network_id": 1,
  "tx_hash": "0x0294dae3cfb26881e5dde9f182531aa5be0818956d029d50e9872543f020df2e",
  "claim_tx_hash": "",
  "metadata": "0x",
  "ready_for_claim": true,
  "global_index": "9075"
}

If we want to claim this deposit, we can use a command like this:

polycli ulxly claim asset \
    --bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \
    --bridge-service-url https://bridge-api.cardona.zkevm-rpc.com \
    --private-key 0x32430699cd4f46ab2422f1df4ad6546811be20c9725544e99253a887e971f92b \
    --deposit-network 1 \
    --deposit-count 9075 \
    --rpc-url https://sepolia.drpc.org

Here is the transaction that was created and mined based on this command.

Flags

  -h, --help   help for asset

The command also inherits flags from parent commands.

      --bridge-address string              address of the lxly bridge
      --bridge-service-url string          URL of the bridge service
      --chain-id string                    chain ID to use in the transaction
      --config string                      config file (default is $HOME/.polygon-cli.yaml)
      --deposit-count uint32               deposit count of the bridge transaction
      --deposit-network uint32             rollup ID of the network where the deposit was made
      --destination-address string         destination address for the bridge
      --dry-run                            do all of the transaction steps but do not send the transaction
      --gas-limit uint                     force specific gas limit for transaction
      --gas-price string                   gas price to use
      --global-index string                an override of the global index value
      --insecure                           skip TLS certificate verification
      --legacy                             force usage of legacy bridge service (default true)
      --pretty-logs                        output logs in pretty format instead of JSON (default true)
      --private-key string                 hex encoded private key for sending transaction
      --proof-ger string                   if specified and using legacy mode, the proof will be generated against this GER
      --proof-l1-info-tree-index uint32    if specified and using aggkit mode, the proof will be generated against this L1 Info Tree Index
      --rpc-url string                     RPC URL to send the transaction
      --transaction-receipt-timeout uint   timeout in seconds to wait for transaction receipt confirmation (default 60)
  -v, --verbosity string                   log level (string or int):
                                             0   - silent
                                             100 - panic
                                             200 - fatal
                                             300 - error
                                             400 - warn
                                             500 - info (default)
                                             600 - debug
                                             700 - trace (default "info")
      --wait duration                      retry claiming until deposit is ready, up to specified duration (available for claim asset and claim message)

See also