Junø
WebDiscordGithubTwitter
  • Juno
    • Intro
    • Home of CosmWasm
    • Contributors - Core Software
    • Brand Identity
    • Security Disclosures
    • Economic Overview
      • Disclaimer
      • Native Asset (JUNO)
      • Incentive structure
      • Supply API - Data
  • Developer Guides
    • CosmWasm Contracts
      • Compile a Contract
      • Deploy a Contract
      • Guide: How to Upload a Smart Contract on the Juno Chain
      • Use Cw-orchestrator to speed-up your development
      • Query A Contract
      • Send Tokens to a Contract
    • Miscellaneous
      • Conversions
      • Multi Message Transaction
      • Get & Decode Transactions
      • Get Token Prices
      • Get Account Transactions
      • IBC Transfer
      • State Export / Airdrop
    • Juno Modules
      • FeeShare
      • TokenFactory
    • API Endpoints
      • Cosmos
        • Tx
          • V1beta1
            • Simulate
            • Txs
              • Block
        • Params
          • V1beta1
            • Params
        • Bank
          • V1beta1
            • Balances
              • By denom
            • Denoms metadata
            • Params
            • Spendable balances
            • Supply
        • Upgrade
          • V1beta1
            • Applied plan
            • Current plan
            • Module versions
            • Upgraded consensus state
        • Auth
          • V1beta1
            • Accounts
            • Module accounts
            • Params
        • Staking
          • V1beta1
            • Delegations
            • Historical info
            • Params
            • Pool
            • Validators
              • Delegations
                • Unbonding delegation
              • Unbonding delegations
            • Delegators
              • Redelegations
              • Unbonding delegations
              • Validators
        • Evidence
          • V1beta1
            • Evidence
        • Mint
          • V1beta1
            • Annual provisions
            • Inflation
            • Params
        • Feegrant
          • V1beta1
            • Allowance
            • Allowances
            • Issued
        • Gov
          • V1beta1
            • Params
            • Proposals
              • Deposits
              • Tally
              • Votes
        • Distribution
          • V1beta1
            • Community pool
            • Params
            • Delegators
              • Rewards
              • Validators
              • Withdraw address
            • Validators
              • Commission
              • Outstanding rewards
              • Slashes
        • Slashing
          • V1beta1
            • Params
            • Signing infos
        • Authz
          • V1beta1
            • Grants
              • Grantee
              • Granter
        • Base
          • Tendermint
            • V1beta1
              • Blocks
                • Latest
              • Node info
              • Syncing
              • Validatorsets
                • Latest
          • Node
            • V1beta1
              • Config
      • Cosmwasm
        • Wasm
          • V1
            • Code
              • Contracts
            • Contract
              • History
              • Raw
              • Smart
              • State
            • Codes
              • Params
              • Pinned
            • Contracts
              • Creator
      • Juno
        • Feeshare
          • V1
            • Fee shares
            • Params
        • Tokenfactory
          • V1beta1
            • Denoms from creator
            • Params
            • Denoms
              • Authority metadata
      • Ibc
        • Apps
          • Router
            • V1
              • Params
      • API Specification
    • Local Interchain
      • Local Interchain Rust Example
    • Junod Local Dev Setup
    • Integrate Leap wallet
    • SubQuery Indexer
  • Governance
    • Before submitting a proposal
    • Submitting a Proposal (CLI)
      • Formatting Proposal Markdown
  • Command-Line Interface (CLI)
    • Introduction
    • Useful CLI Commands
    • Module Reference
      • bank
      • distribution
      • gov
      • keys
      • params
      • slashing
      • staking
      • status
      • tendermint
      • upgrade
      • wasm
  • Nodes & Validators
    • Junod Installation and setup
    • Setting up Cosmovisor
    • Mainnet Setup and Tooling
    • Joining Mainnet
      • Sync from Snapshot
      • Sync with state-sync
      • Mainnet Upgrades
    • Joining Testnet
    • Relaying
    • Juno Delegations Program
Powered by GitBook
On this page

Was this helpful?

  1. Developer Guides
  2. Miscellaneous

IBC Transfer

How to transfer tokens from networks in Cosmos

PreviousGet Account TransactionsNextState Export / Airdrop

Last updated 2 years ago

Was this helpful?

One of the highlighted features of CosmosSDK chains is the ability to transfer tokens permissionless to other chains in the network. This is also possible with Juno to and from other chains. If you are just looking for a simple frontend to transfer tokens, and frontends both have deposit and withdraw UIs to do this. If you need to transfer tokens between Juno and another chain that does not have a frontend, or is new, you can use to seamlessly transfer between networks.

Typescript

If you wish to make a IBC transfer between chains, you will need to leverage cosmos directory & .

// Pseudo Code Example of the Flow
import { assets, chains, ibc } from 'chain-registry';
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
import { setupIbcExtension, QueryClient } from '@cosmjs/stargate';
import type {IbcExtension} from '@cosmjs/stargate/build/modules/ibc/queries';

const JUNO_RPC = "https://rpc.juno.strange.love"

const get_wallet_for_chain = async (
    chain_id: string
): Promise<OfflineAminoSigner | OfflineDirectSigner> => {
    // open keplr
    const keplr = window as KeplrWindow;
    if (keplr === undefined) {
        toast.error(`Keplr not found`, toast_style);
        throw new Error('Keplr not found');
    }
    // ledger support
    let signer = keplr.getOfflineSignerAuto;
    if (signer === undefined) {
        throw new Error('Keplr not found');
    }
    return signer(chain_id);
};


const tm_client = await Tendermint34Client.connect(JUNO_RPC);
let temp = QueryClient.withExtensions(tm_client);
let query_client: IbcExtension = setupIbcExtension(temp);

let from_wallet = await get_wallet_for_chain("juno-1");
let to_wallet = await get_wallet_for_chain("osmosis-1");

let from_client: SigningStargateClient | undefined;
from_client = await SigningStargateClient.connectWithSigner(
    JUNO_RPC, 
    from_wallet,
    {prefix: "juno"}
);

const addr = (await wallet.getAccounts())[0].address;

const from_addr = (await from_wallet.getAccounts())[0].address;
const to_addr = (await to_wallet.getAccounts())[0].address;

const channel_id = 0 // JUNO->OSMOSIS is channel 0
const timeout_time = current_time + 300; // 5 minutes
const gas = 300000;

from_client
    .sendIbcTokens(
        from_addr,
        to_addr,
        { denom: "ujuno", amount: "1000000" },
        'transfer',
        channel_id,
        undefined,
        timeout_time,
        { amount: [], gas: gas.toString() },
        `memo: IBC Transfer of 1000000 ujuno to osmosis chain`
    )
    .then((tx) => {
        console.log(tx);
        if (tx.code == 0) {
            alert(
                `IBC transfer from ${chain.pretty_name} successful\n\nTxHash: ${tx.transactionHash}`
            )
        }				
    })
Osmosis
Wynd Dex
ibc-anywhere
Cosmology's stack in your webapp
CosmJS sendIBCTokens Docs
Example in Action from ibc-anywhere-webapp