Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
Transaction Types and Usage

ArcBridge Transactions


ArcBridge provides a mechanism to create and manage dedicated sub-chains on the OCAP platform. These transactions are essential for the entire lifecycle of an ArcBridge, from its creation and operation to its eventual conclusion. The @ocap/client library offers a suite of helper methods to simplify the process of sending these transactions, which internally use transaction types like CreateRollupTx, UpdateRollupTx, and others.

This document covers the specific transaction types for creating, managing, and interacting with an ArcBridge. For a higher-level understanding of transactions, please see the Transaction Types Overview.

ArcBridge Lifecycle#

The lifecycle of an ArcBridge involves several stages, each managed by specific transactions. Validators can join, propose blocks, and earn rewards, while administrators can update configurations or pause the chain if needed.

JoinRollupTx

UpdateRollupTx

PauseRollupTx

ResumeRollupTx

LeaveRollupTx

CloseRollupTx

CreateRollupTx

ArcBridge Active

Validator Joins

CreateRollupBlockTx

ClaimBlockRewardTx

ArcBridge Paused

Validator Leaves

ArcBridge Closed


Create an ArcBridge#

To initialize a new sub-chain, you use the createRollup helper method. This transaction registers the ArcBridge on the main chain, setting its fundamental parameters, such as the associated token, validator requirements, and operational rules.

Method: client.createRollup(props, extra)

Parameters

Name

Type

Description

wallet

WalletObject

The wallet of the ArcBridge creator.

tokenAddress

string

The address of the token used within the ArcBridge.

vaultAddress

string

The address of the vault for holding fees and rewards.

contractAddress

string

The address of the smart contract governing the ArcBridge logic.

seedValidators

Array<TRollupValidator>

An array of initial validators for the ArcBridge.

minStakeAmount

string

The minimum amount of tokens a validator must stake.

maxStakeAmount

string

The maximum amount of tokens a validator can stake.

minSignerCount

number

The minimum number of validators required to sign a block.

maxSignerCount

number

The maximum number of validators allowed.

minBlockSize

number

The minimum number of transactions in a block.

maxBlockSize

number

The maximum number of transactions in a block.

minBlockInterval

number

The minimum time interval (in seconds) between blocks.

...

any

Other optional parameters to configure the ArcBridge, as defined in TCreateRollupTx.

Example

This example demonstrates how to create a new ArcBridge with basic configuration.

import Client from '@ocap/client';
import { fromRandom } from '@ocap/wallet';

const client = new Client('https://beta.abtnetwork.io/api');
const wallet = fromRandom(); // Creator's wallet

async function createNewArcBridge() {
try {
// In a real application, ensure the creator's wallet has funds.
// await client.checkin(wallet.address);

const props = {
wallet,
tokenAddress: 'z35n6aTDRr3s5a41d3e8e16e6a1a1a7c78e3f', // Example token address
vaultAddress: 'z1AdA5wS5f4f6g7h8j9k0l2m3n4p5q6r7s8t',
contractAddress: 'z2BdA5wS5f4f6g7h8j9k0l2m3n4p5q6r7s8t',
seedValidators: [{ address: wallet.address, power: '100' }],
minStakeAmount: '1000000000000000000', // 1 unit of the token
minSignerCount: 1,
maxSignerCount: 3,
};

const [hash, address] = await client.createRollup(props);
console.log('ArcBridge creation tx hash:', hash);
console.log('New ArcBridge address:', address);
} catch (error) {
console.error('Error creating ArcBridge:', error);
}
}

createNewArcBridge();

Example Response

The method returns a tuple containing the transaction hash and the newly created ArcBridge's DID address.

[
"0xabf3a8b3d8f8c8a1e8f8d8f8a8f8d8a8f8d8a8f8d8a8f8d8a8f8d8a8f8d8a8f8",
"zrwjpZa1d1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1A1B1C"
]


Update an ArcBridge#

Administrators can modify the parameters of an existing ArcBridge by sending an UpdateRollupTx.

Method: client.sendUpdateRollupTx({ tx, wallet }, extra)

Parameters (tx.itx)

Name

Type

Description

rollup

string

The address of the ArcBridge to update.

minStakeAmount

string

(Optional) The new minimum stake amount.

maxStakeAmount

string

(Optional) The new maximum stake amount.

...

any

Other updatable parameters as defined in TUpdateRollupTx.

Example

async function updateMyArcBridge(arcBridgeAddress, newMinStake) {
try {
const hash = await client.sendUpdateRollupTx({
tx: {
itx: {
rollup: arcBridgeAddress,
minStakeAmount: newMinStake, // e.g., '2000000000000000000'
},
},
wallet, // The wallet must have administrative rights
});
console.log('Update ArcBridge tx hash:', hash);
} catch (error) {
console.error('Error updating ArcBridge:', error);
}
}


Manage Validators (Join/Leave)#

Validators can join or leave an ArcBridge, which involves staking and multi-party signatures to ensure consensus.

Join an ArcBridge#

A new validator joins by sending a JoinRollupTx.

Method: client.sendJoinRollupTx({ tx, wallet }, extra)

Parameters (tx.itx)

Name

Type

Description

rollup

string

The address of the ArcBridge to join.

endpoint

string

The endpoint URL for the new validator.

signatures

Array<TMultisig>

Signatures from existing validators authorizing the join.

Leave an ArcBridge#

A validator leaves by sending a LeaveRollupTx.

Method: client.sendLeaveRollupTx({ tx, wallet }, extra)

Parameters (tx.itx)

Name

Type

Description

rollup

string

The address of the ArcBridge to leave.

signatures

Array<TMultisig>

Signatures from other validators authorizing the departure.


Block Operations#

Validators are responsible for creating new blocks, and publishers can claim rewards for finalized blocks.

Create an ArcBridge Block#

A proposer creates a new block by sending a CreateRollupBlockTx.

Method: client.sendCreateRollupBlockTx({ tx, wallet }, extra)

Parameters (tx.itx)

Name

Type

Description

rollup

string

The address of the ArcBridge.

height

number

The new block height.

hash

string

The hash of the new block.

previousHash

string

The hash of the previous block.

merkleRoot

string

The Merkle root of the transactions in the block.

txs

Array<string>

A list of transaction hashes included in the block.

proposer

string

The address of the block proposer.

signatures

Array<TMultisig>

Signatures from the required number of validators.

Claim Block Reward#

A publisher claims the reward for a confirmed block by sending a ClaimBlockRewardTx.

Method: client.sendClaimBlockRewardTx({ tx, wallet }, extra)

Parameters (tx.itx)

Name

Type

Description

rollup

string

The address of the ArcBridge.

blockHeight

number

The height of the block for which the reward is being claimed.

blockHash

string

The hash of the block.

publisher

string

The address of the publisher claiming the reward.


Lifecycle Control (Pause/Resume)#

Administrators can pause and resume an ArcBridge for maintenance or other reasons.

Pause an ArcBridge#

Method: client.sendPauseRollupTx({ tx, wallet }, extra)

async function pauseMyArcBridge(arcBridgeAddress) {
try {
const hash = await client.sendPauseRollupTx({
tx: { itx: { rollup: arcBridgeAddress } },
wallet, // The wallet must have administrative rights
});
console.log('Pause ArcBridge tx hash:', hash);
} catch (error) {
console.error('Error pausing ArcBridge:', error);
}
}

Resume an ArcBridge#

Method: client.sendResumeRollupTx({ tx, wallet }, extra)

async function resumeMyArcBridge(arcBridgeAddress) {
try {
const hash = await client.sendResumeRollupTx({
tx: { itx: { rollup: arcBridgeAddress } },
wallet, // The wallet must have administrative rights
});
console.log('Resume ArcBridge tx hash:', hash);
} catch (error) {
console.error('Error resuming ArcBridge:', error);
}
}


Now that you understand how to manage the ArcBridge lifecycle, you may want to explore the full range of client capabilities in the API Reference.