var img = document.createElement('img'); img.src = "https://terradocs.matomo.cloud//piwik.php?idsite=1&rec=1&url=https://docs.terra.money" + location.pathname; img.style = "border:0"; img.alt = "tracker"; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(img,s);
Skip to main content

IBC Transfers

Terra has full IBC transfer capability through both Feather.js and Station. Although IBC functionality is not readily exposed through Station’s front end, it can be incorporated into any dApp. It is up to a dApp’s front end to initiate IBC transfers.

MsgTransfer

Feather.js exports a MsgTransfer class that can be used to construct IBC transfers.


_10
new MsgTransfer(
_10
'transfer', // IBC port
_10
'channel-1', // Outbound channel (Osmosis)
_10
new Coin('uluna', '1000000'), // 1 LUNA
_10
'terra1cvw8sundusurqajhurpcfk7yvuzlh92cvkpy28', // Source Address on Terra
_10
'osmo1cl4qw7u35uf77l4scjtv0qej8ycevu4mrdpvmg', // Destination address on Osmosis
_10
undefined, // Timeout block height (optional)
_10
(Date.now() + 60 * 1000) * 1e6, // Timeout timestamp (in nanoseconds) relative to the current block timestamp.
_10
'field can be used to send notes, interact with ibc-hooks, packet-middleware, etc...', // Memo field
_10
);

Supported Channels

Channels are defined when a relayer is set up between Terra and an external chain. For each new connected chain, the channel ID is incremented.

You can use the Map of Zones to find the available channels and their IDs.

Derive Cosmos chain addresses from a Terra address

Cosmos SDK-based blockchains use bech32 to encode the public key for display. Assuming the same private key is used on multiple Cosmos SDK chains, it is possible to decode a Terra address and generate the corresponding public key on another chain.

Here's a quick example using the bech32 JavaScript library:


_5
import { bech32 } from 'bech32';
_5
_5
const terraAddress = 'terra1cvw8sundusurqajhurpcfk7yvuzlh92cvkpy28';
_5
const decodedAddress = bech32.decode(terraAddress);
_5
const osmosisAddress = bech32.encode('osmo', decodedAddress.words);

Complete example

The following example demonstrates how to send 1 LUNA from Terra to the Osmosis blockchain.


_35
import {
_35
LCDClient,
_35
MnemonicKey,
_35
MsgTransfer,
_35
Coin,
_35
} from '@terra-money/feather.js';
_35
_35
// const lcd = new LCDClient(...);
_35
_35
const mk = new MnemonicKey({
_35
mnemonic:
_35
'satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn',
_35
});
_35
_35
const wallet = lcd.wallet(mk);
_35
_35
// Send 1 LUNA to the Osmosis blockchain.
_35
const transfer = new MsgTransfer(
_35
'transfer',
_35
'channel-1',
_35
new Coin('uluna', '1000000'),
_35
'terra1cvw8sundusurqajhurpcfk7yvuzlh92cvkpy28',
_35
'osmo1cl4qw7u35uf77l4scjtv0qej8ycevu4mrdpvmg',
_35
undefined,
_35
(Date.now() + 60 * 1000) * 1e6,
_35
'hello world',
_35
);
_35
_35
const tx = await wallet.createAndSignTx({
_35
msgs: [transfer],
_35
chainID: 'pisco-1',
_35
});
_35
const result = await lcd.tx.broadcast(tx, 'pisco-1');
_35
_35
console.log(result);

Instructions for initializing LCDClient can be found in the common examples section.