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.
unique key
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
| Parameter | Type |
|---|---|
options | GatewayWritesOptions |
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.
gateway writes options invalid option resolve token class key wallet address timeout unique prefix
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
walletAddress | readonly | string | The identity every write is made as, in the spelling the gateway receives. |
wallet address
Methods
burnTokens()
burnTokens(
input):Promise<GatewayWriteReceipt>
Burn 1 to 50 tokens of the writer's. IRREVERSIBLE: burned tokens are gone.
Parameters
| Parameter | Type |
|---|---|
input | BurnTokensInput |
Returns
Promise<GatewayWriteReceipt>
Throws
GalaSDKError as transferToken, plus INVALID_TOKEN_BATCH.
burn tokens gateway write receipt input invalid token batch
lockTokens()
lockTokens(
input):Promise<GatewayWriteReceipt>
Lock 1 to 100 tokens of the writer's under one hold.
Parameters
| Parameter | Type |
|---|---|
input | LockTokensInput |
Returns
Promise<GatewayWriteReceipt>
Throws
GalaSDKError as burnTokens, plus INVALID_LOCK_EXPIRES, INVALID_LOCK_NAME.
lock tokens gateway write receipt input invalid expires name
transferGala()
transferGala(
input):Promise<GatewayWriteReceipt>
Transfer GALA (GALA|Unit|none|none, instance "0") to to.
Parameters
| Parameter | Type |
|---|---|
input | TransferGalaInput |
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.
transfer gala gateway write receipt input invalid wallet address quantity unique key signing failed outcome unknown rejected http error response
transferToken()
transferToken(
input):Promise<GatewayWriteReceipt>
Transfer one token to to.
Parameters
| Parameter | Type |
|---|---|
input | TransferTokenInput |
Returns
Promise<GatewayWriteReceipt>
Throws
GalaSDKError as transferGala, plus INVALID_TOKEN_REFERENCE,
NO_TOKEN_NAME_RESOLVER, TOKEN_NAME_RESOLUTION_FAILED.
transfer token gateway write receipt input invalid reference no name resolver resolution failed
unlockTokens()
unlockTokens(
input):Promise<GatewayWriteReceipt>
Unlock 1 to 100 tokens of the writer's from their hold.
Parameters
| Parameter | Type |
|---|---|
input | UnlockTokensInput |
Returns
Promise<GatewayWriteReceipt>
Throws
GalaSDKError as burnTokens, plus INVALID_LOCK_NAME.
unlock tokens gateway write receipt input invalid lock name