diff --git a/examples/p-chain/export.ts b/examples/p-chain/export.ts index 5f1f13c60..ecd108650 100644 --- a/examples/p-chain/export.ts +++ b/examples/p-chain/export.ts @@ -7,11 +7,10 @@ import { pvmapi } from '../chain_apis'; import { getChainIdFromContext } from '../utils/getChainIdFromContext'; const P_CHAIN_ADDRESS = process.env.P_CHAIN_ADDRESS; -const X_CHAIN_ADDRESS = process.env.X_CHAIN_ADDRESS; const PRIVATE_KEY = process.env.PRIVATE_KEY; -const main = async () => { - if (!P_CHAIN_ADDRESS || !X_CHAIN_ADDRESS || !PRIVATE_KEY) { +const main = async (destinationChain: 'C' | 'X') => { + if (!P_CHAIN_ADDRESS || !PRIVATE_KEY) { throw new Error('Missing environment variable(s).'); } @@ -23,12 +22,12 @@ const main = async () => { const tx = newExportTx( context, - getChainIdFromContext('X', context), + getChainIdFromContext(destinationChain, context), [bech32ToBytes(P_CHAIN_ADDRESS)], utxos, [ TransferableOutput.fromNative(context.avaxAssetID, BigInt(0.1 * 1e9), [ - bech32ToBytes(X_CHAIN_ADDRESS), + bech32ToBytes(P_CHAIN_ADDRESS), ]), ], ); @@ -41,4 +40,4 @@ const main = async () => { return pvmapi.issueSignedTx(tx.getSignedTx()); }; -main().then(console.log); +main('C').then(console.log);