Skip to main content

index/classes/GatewayWrites.md

Signed GalaChain token-contract writes through the gateway: transfer GALA, transfer a token, burn, lock and unlock. React Native safe (no Node builtins, no ethers, no @gala-chain/api).

Every write is checked completely BEFORE it is signed (recipient and owner spellings, the token, the quantity, the uniqueKey, the batch), so a refused input costs no signature and no request. The DTO is plain JSON with exactly the chain's fields; the signer signs it as it is (nothing, least of all a signer hint, is added) and the body sent is what the signer returned. Quantities are whole tokens and are signed exactly as written.

Example​

const writes = new GatewayWrites({
gatewayBaseUrl: 'https://gateway-mainnet.galachain.com',
signer: new PrivateKeySigner(privateKey),
walletAddress: 'eth|70997970C51812dc3A010C7d01b50e0d17dc79C8',
});
const { transactionId, blockNumber } = await writes.transferGala({ to: 'client|abc', quantity: '1.5' });

Constructors​

Constructor​

new GatewayWrites(options): GatewayWrites

Parameters​

ParameterType
optionsGatewayWritesOptions

Returns​

GatewayWrites

Throws​

GalaSDKError INVALID_WRITES_OPTION (a missing signer or base URL, a requestor that is not a function, a resolver without resolveTokenClassKey), INVALID_WALLET_ADDRESS, INVALID_TIMEOUT, INVALID_UNIQUE_KEY_PREFIX.

Properties​

PropertyModifierTypeDescription
walletAddressreadonlystringThe identity every write is made as, in the spelling the gateway receives.

Methods​

burnTokens()​

burnTokens(input): Promise<GatewayWriteReceipt>

Burn 1 to 50 tokens of the writer's. IRREVERSIBLE: burned tokens are gone.

Parameters​

ParameterType
inputBurnTokensInput

Returns​

Promise<GatewayWriteReceipt>

Throws​

GalaSDKError as transferToken, plus INVALID_TOKEN_BATCH.


lockTokens()​

lockTokens(input): Promise<GatewayWriteReceipt>

Lock 1 to 100 tokens of the writer's under one hold.

Parameters​

ParameterType
inputLockTokensInput

Returns​

Promise<GatewayWriteReceipt>

Throws​

GalaSDKError as burnTokens, plus INVALID_LOCK_EXPIRES, INVALID_LOCK_NAME.


transferGala()​

transferGala(input): Promise<GatewayWriteReceipt>

Transfer GALA (GALA|Unit|none|none, instance "0") to to.

Parameters​

ParameterType
inputTransferGalaInput

Returns​

Promise<GatewayWriteReceipt>

Throws​

GalaSDKError pre-send: INVALID_WALLET_ADDRESS, INVALID_QUANTITY, INVALID_UNIQUE_KEY, SIGNING_FAILED; in flight: GATEWAY_WRITE_OUTCOME_UNKNOWN (check error.uniqueKey; never resend under a fresh key); post-send: GATEWAY_WRITE_REJECTED, GATEWAY_HTTP_ERROR, GATEWAY_RESPONSE_INVALID.


transferToken()​

transferToken(input): Promise<GatewayWriteReceipt>

Transfer one token to to.

Parameters​

ParameterType
inputTransferTokenInput

Returns​

Promise<GatewayWriteReceipt>

Throws​

GalaSDKError as transferGala, plus INVALID_TOKEN_REFERENCE, NO_TOKEN_NAME_RESOLVER, TOKEN_NAME_RESOLUTION_FAILED.


unlockTokens()​

unlockTokens(input): Promise<GatewayWriteReceipt>

Unlock 1 to 100 tokens of the writer's from their hold.

Parameters​

ParameterType
inputUnlockTokensInput

Returns​

Promise<GatewayWriteReceipt>

Throws​

GalaSDKError as burnTokens, plus INVALID_LOCK_NAME.