Skip to content

Latest commit

 

History

History
80 lines (60 loc) · 3.18 KB

shielded-ibc.mdx

File metadata and controls

80 lines (60 loc) · 3.18 KB

import { Callout } from 'nextra-theme-docs'

Shielded IBC

You can send assets to another IBC compliant chain, such as a Cosmos SDK chain or another Namada chain, using the ibc-transfer command in namadac.

This section covers sending assets to and from a shielded ( znam ) address.

Prerequisites

  • An active IBC connection has been created and maintained between the two chains by operators running relayer software such as Hermes.
  • You will need to know the corresponding channel ID.

IBC transfer to a shielded address

First, we need to generate the shielding data with the command:

namadac ibc-gen-shielding \
  --output-folder-path \
  $OUTPUT_FOLDER_PATH \
  --target \
  $RECEIVER \
  --token \
  $TOKEN \
  --amount \
  $AMOUNT \
  --port-id
  $PORT_ID \
  --channel-id \
  $CHANNEL_ID

This command will generate the shielding data in a file inside the provided directory and will output the path to this file, $SHIELDING_DATA_PATH.

After that, IBC transfers to a shielded address work similarly to those for a transparent address, the only differences being that we provide the MASP internal address as the value instead of $RECV_ADDRESS and we add a --memo arg with the path to the file we have just generated:

gaiad tx ibc-transfer transfer \
  $CHANNEL_ID \
  $MASP_ADDRESS \
  ${AMOUNT}${IBC_TOKEN_ADDRESS} \
  --from $COSMOS_ALIAS \
  --node $COSMOS_RPC_ENDPOINT \
  --fees 5000uatom \
  --memo $SHIELDING_DATA_PATH
The previous command would work even with `$RECEIVER_PAYMENT_ADDRESS` as the second argument, but it is highly recommended to use `$MASP_ADDRESS` to preserve privacy.

IBC transfer from a shielded address

You can also send IBC transfers from a shielded address, by providing the associated spending key as the source:

namadac ibc-transfer \
  --source $SOURCE_SPEND_KEY \
  --receiver $RECV_ADDRESS \
  --token $TOKEN \
  --amount $AMOUNT \
  --channel-id $CHANNEL_ID \

Gas fees can be paid like all the other transactions either directly from an implicit account adding --gas-payer $IMPLICIT_ADDRESS or via the MASP. For more information please refer to the fees section.

Refund when IBC transfer failure

The token should be refunded when the IBC transfer fails.

--refund-target can be set to specify the address to be refunded only if you send tokens from a shielded address. In a transparent IBC transfer, tokens will be refunded to the source address.

The refund target address will receive the refund if --refund-target is given. You can set a transparent or a payment address for the refund target.

If no --refund-target is given in a transfer from a shielded address, a generated transparent address whose alias is prefixed with ibc-refund-target and the token will be refunded to the transparent address.

Please note that it is impossible to refund to the payment address when the refund happens after the MASP epoch when the transfer has started. In this case, the tokens will be refunded to the fallback transparent address that is automatically generated when a payment address is set to the refund target.