3. Interchain Message
OP bridge deposit
> initiad tx ophost initiate-token-deposit [bridge_id] [addr] 1000000uinit ''\
--from [key-name] \
--gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
--node [rpc-url]:[rpc-port] --chain-id [chain-id]import {
Coin,
LCDClient,
MnemonicKey,
MsgInitiateTokenDeposit,
Wallet,
} from '@initia/initia.js';
async function initiateTokenDeposit() {
const lcd = new LCDClient('[rest-url]', {
gasPrices: '0.15uinit',
gasAdjustment: '1.5',
});
const key = new MnemonicKey({
mnemonic:
'beauty sniff protect ...',
});
const wallet = new Wallet(lcd, key);
const msgs = [
new MsgInitiateTokenDeposit(
key.accAddress, // sender
3, // bridge id
'init1gegp28h8n7lv85ydltycenmw8dndn9umnn697q', // reciever
new Coin('uinit', 1) // coin
),
];
// sign tx
const signedTx = await wallet.createAndSignTx({ msgs });
// send(broadcast) tx
await lcd.tx.broadcastSync(signedTx).then(res => console.log(res));
// {
// height: 0,
// txhash: '162AA29DE237BD060EFEFFA862DBD07ECD1C562EBFDD965AD6C34DF856B53DC2',
// raw_log: '[]'
// }
}
initiateTokenDeposit();
OP bridge withdraw
> minitiad tx opchild withdraw [addr] [amount]\
--from [key-name] \
--gas auto --gas-adjustment 1.5 --gas-prices [l2_gas_price] \
--node [rpc-url]:[rpc-port] --chain-id [chain-id]import {
Coin,
LCDClient,
MnemonicKey,
MsgInitiateTokenWithdrawal,
Wallet,
} from '@initia/initia.js';
async function initiateTokenWithdraw() {
const lcd = new LCDClient('[l2-rest-url]', {
gasPrices: '0.15unova', // gas price in your l2 denom
gasAdjustment: '1.5',
});
const key = new MnemonicKey({
mnemonic:
'beauty sniff protect ...',
});
const wallet = new Wallet(lcd, key);
const msgs = [
new MsgInitiateTokenWithdrawal(
key.accAddress, // sender
'init1gegp28h8n7lv85ydltycenmw8dndn9umnn697q', // reciever
new Coin('l2/...', 1) // coin
),
];
// sign tx
const signedTx = await wallet.createAndSignTx({ msgs });
// send(broadcast) tx
await lcd.tx.broadcastSync(signedTx).then(res => console.log(res));
// {
// height: 0,
// txhash: '162AA29DE237BD060EFEFFA862DBD07ECD1C562EBFDD965AD6C34DF856B53DC2',
// raw_log: '[]'
// }
}
initiateTokenWithdraw();
OP bridge finalize token withdrawal
IBC token transfer
IBC NFT transfer
Last updated