UNPKG

@mysten/sui

Version:
72 lines (57 loc) 1.77 kB
# Building Offline > Build transactions without a network connection To build a transaction offline (with no `client` required), you need to fully define all of your inputs, gas configuration, and expiration. ## Required Configuration When building offline, you must set the following: - **Sender address** - The address that will execute the transaction - **Gas price** - The price per gas unit (can be obtained from the network beforehand) - **Gas budget** - The maximum gas to spend on this transaction - **Gas payment** - One or more coin object references to use for gas, or an empty array for Address Balances - **Expiration** - Only needed when using address balances for gas ```tsx const { referenceGasPrice } = await client.getReferenceGasPrice(); const tx = new Transaction(); tx.setSender('0x<your-address>'); tx.setGasPrice(referenceGasPrice); tx.setGasBudget(50_000_000); tx.setGasPayment([ { objectId: '0x<gas-coin-object-id>', version: '<object-version>', digest: '<object-digest>', }, ]); // Build the transaction without a client const bytes = await tx.build(); ``` ## Object References For objects used in your transaction, you must provide full object references using the `Inputs` helper: ```tsx // For owned or immutable objects tx.object( Inputs.ObjectRef({ objectId: '0x<object-id>', version: '<object-version>', digest: '<object-digest>', }), ); // For shared objects tx.object( Inputs.SharedObjectRef({ objectId: '0x<object-id>', initialSharedVersion: '<initial-shared-version>', mutable: true, }), ); // For receiving objects (objects being received by another object) tx.object( Inputs.ReceivingRef({ objectId: '0x<object-id>', version: '<object-version>', digest: '<object-digest>', }), ); ```