GUM Docs
Open GUM

Trading API

Sign with your wallet

What a quote's message and transaction are, how your signature becomes a GUM Network typed signature, and how to sign with a Solana or EVM key in JavaScript, Python, Rust or Go, or with a browser wallet.

Every quote returns two base64 strings:

  • transaction: the whole GUM Network transaction, in its wire format. Send it back unchanged.
  • message: the part of transaction that signatures cover. Sign these bytes with your wallet.

The quote’s signer.address is the GUM account that must sign, and signer.signWith says how: solana or evm. In the examples, message is the decoded bytes.

What’s in the transaction

A GUM Network transaction is a Solana legacy message with typed signature records in front, one per signer. Each record is a length, a one-byte type tag and the signature, and record i signs for account i of the message. GUM’s fee payer comes first and has already signed, so every quote starts like this:

Layout
offset   bytes      meaning
0        02         2 records: GUM's fee payer, then you
1        41 00      length 65, tag 0x00 (Ed25519)
3–66     64 bytes   the fee payer's signature
67       41 00      length 65, tag 0x00
69–132   64 zeros   your slot, empty until you sign
133–     …          the Solana legacy message: message

You never build a record, and a Solana SDK can’t: it writes bare 64-byte signatures, without the length and tag. Sign message the way your wallet signs anything and send only the signature. The API turns it into your typed signature, checks it against message exactly as GUM Network validators will, writes it into your slot and submits the transaction:

signWithYou sendYour record becomes
solanaThe 64-byte Ed25519 signature41 (length 65), 00, then the signature: 66 bytes
evmThe 65-byte personal_sign signature: r, s, v82 01 (length 130), 10, then your 65-byte public key, r and s: 132 bytes

For an EVM wallet, the API recovers your public key from the signature and drops v, because a typed signature carries the key instead. It also switches a high s to the low form GUM Network requires.

Your account is the address your record signs for. For a Solana wallet, that’s its public key. For an EVM wallet, it’s a typed address built from your 0x address and tag 0x10. Pass either form as address.

Solana keys

Sign the raw message bytes with Ed25519. Send the 64-byte signature as base58, base64 or hex.

import bs58 from "bs58";
import nacl from "tweetnacl";

const signature = bs58.encode(nacl.sign.detached(message, secretKey));

Solana browser wallets

Wallets don’t sign arbitrary bytes that look like a transaction, so wrap message in one and ask the wallet to sign it. The signature covers the same bytes. This is how the GUM app signs. Send only your signature: the transaction the wallet returns is in Solana’s format, which GUM Network can’t read.

JavaScript
import { VersionedMessage, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";

const solanaMessage = VersionedMessage.deserialize(message);
const signed = await wallet.signTransaction(
  new VersionedTransaction(solanaMessage)
);
const index = solanaMessage.staticAccountKeys.findIndex((key) =>
  key.equals(wallet.publicKey)
);
const signature = bs58.encode(signed.signatures[index]);

Perps order and cancel quotes

Perps margin deposits, withdrawals and leverage updates return a GUM Network transaction message (sign them with signTransaction above). Perps order (/v1/perps/orders/quote) and cancel (/v1/perps/orders/cancel/quote) quotes instead return serialized GUM Perps action bytes, not a Solana transaction message. Decode message from base64 and sign those bytes directly with wallet.signMessage:

JavaScript
import bs58 from "bs58";

const bytes = Uint8Array.from(atob(quote.message), (c) => c.charCodeAt(0));
const signatureBytes = await wallet.signMessage(bytes);
const signature = bs58.encode(signatureBytes);

Raw Solana keys (Ed25519 over the decoded message bytes) and EVM wallets (personal_sign) sign both transaction messages and Perps action bytes the same way.

EVM keys and wallets

Sign the raw message bytes with personal_sign (EIP-191). Send the 65-byte signature as hex.

const signature = await account.signMessage({ message: { raw: message } });