Grid SDK client for account management, authentication, and transactions
Example
import { GridClient } from '@sqds/grid';
const client = new GridClient({
apiKey: 'your-api-key',
environment: 'sandbox'
});
const state = client.account.get();
client.account.on('change', (state) => console.log('Changed:', state));
Properties
| Property | Modifier | Type |
|---|
apiConfig | protected | GridApiConfig |
Accessors
Account Management
account
Get Signature
get account(): AccountManager;
Account manager for reactive state management
Provides access to account state and event subscriptions for reactive updates.
Subscribe to the ‘change’ event to receive notifications when the account state changes.
Example
client.account.on('change', (account) => {
console.log('Account updated:', account);
});
const current = client.account.get();
console.log(current.accountAddress, current.isConnected);
client.account.set('account-address', 'grid-user-id');
client.account.disconnect();
Returns
AccountManager
Methods
Account Management
getAccount()
getAccount(accountAddress): Promise<GetAccountResponse>;
Retrieves comprehensive account details including account type, policies,
signers, thresholds, and metadata.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to retrieve information for |
Returns
Promise<GetAccountResponse>
Promise resolving to account details or error information
Example
const account = await gridClient.getAccount('account-address');
updateAccount()
updateAccount(
accountAddress,
request,
admin?): Promise<TransactionResponse>;
Update account settings and configuration such as policies, signers, thresholds, and metadata.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to update |
request | UpdateAccountRequest | Update request containing the fields to modify |
admin? | boolean | Whether to perform the update with admin privileges (optional) |
Returns
Promise<TransactionResponse>
Promise resolving to transaction response for the update operation
Example
const updateTx = await gridClient.updateAccount(accountAddress, {
policies: {
threshold: 2
}
});
const adminUpdateTx = await gridClient.updateAccount(
accountAddress,
{ policies: { threshold: 1 } },
true
);
getTransfers()
getTransfers(accountAddress, options?): Promise<TransferResponse>;
Retrieves the transaction history for an account, including incoming and
outgoing transfers. Supports filtering by date range, token type, and pagination.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to get transfers for |
options? | GetTransfersOptions | Optional filtering and pagination options |
Returns
Promise<TransferResponse>
Promise resolving to transfers response with transaction history
Example
const transfers = await gridClient.getTransfers(accountAddress);
getTransactions()
getTransactions(accountAddress): Promise<GetTransactionsResponse>;
Retrieves the blockchain transaction history for an account
Returns a list of Solana blockchain transactions associated with the account,
including transaction signatures, statuses, and timestamps. This includes all
on-chain activity for the account.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to get transactions for |
Returns
Promise<GetTransactionsResponse>
Promise resolving to transaction history response
Example
const response = await gridClient.getTransactions(accountAddress);
if (response.data?.transactions) {
response.data.transactions.forEach(tx => {
console.log(tx.signature, tx.status);
});
}
Authentication
initAuth()
initAuth(request): Promise<InitAuthResponse>;
Initialize authentication for an existing user.
This is the first step in the authentication process.
Note: For new users, you must call createAccount first to create an account before initializing authentication. This method is only for authenticating existing users.
Parameters
| Parameter | Type | Description |
|---|
request | | InitAuthRequest | AuthenticationRequest | Authentication request containing email, keypair, or passkey information |
Returns
Promise<InitAuthResponse>
Promise resolving to authentication initialization response with OTP details
Example
const response = await gridClient.initAuth({
email: 'user@example.com'
});
completeAuth()
completeAuth(request): Promise<CompleteAuthResponse>;
This is the second step in email-based authentication. Verifies the OTP
code received via email and establishes an authenticated session.
Note: For new users who need to create an account, use completeAuthAndCreateAccount instead, which completes authentication and creates the account in one step.
Parameters
| Parameter | Type | Description |
|---|
request | CompleteAuthRequestWithOtp | Complete authentication request with OTP code and user context |
Returns
Promise<CompleteAuthResponse>
Promise resolving to authentication completion response with session data
Example
const sessionSecrets = await gridClient.generateSessionSecrets();
const response = await gridClient.completeAuth({
otpCode: '123456',
user: <user object received from initAuth>,
sessionSecrets: sessionSecrets
});
completeAuthAndCreateAccount()
completeAuthAndCreateAccount(request): Promise<CompleteAuthAndCreateAccountResponse>;
Complete authentication and create account (streamlined onboarding)
Parameters
| Parameter | Type | Description |
|---|
request | CompleteAuthAndCreateAccountRequest | Auth completion and account creation request |
Returns
Promise<CompleteAuthAndCreateAccountResponse>
Created account information
Example
const sessionSecrets = await gridClient.generateSessionSecrets();
const account = await gridClient.completeAuthAndCreateAccount({
otpCode: '123456',
user,
sessionSecrets
});
refreshSession()
refreshSession(request): Promise<RefreshSessionResponse>;
Refresh MPC provider session to extend lifetime
Note: Currently supports Privy only. Turnkey refresh not yet implemented.
Parameters
| Parameter | Type | Description |
|---|
request | RefreshSessionRequest | Session refresh request |
Returns
Promise<RefreshSessionResponse>
Refreshed session data
Example
const refreshed = await gridClient.refreshSession({
kmsPayload: { provider: 'privy', session: currentSession },
encryptionPublicKey: encryptionKey
});
createAccount()
createAccount(input): Promise<CreateAccountResponse>;
Creates either an email-based account (requires OTP verification)
or a signer-based account (immediately active).
Parameters
| Parameter | Type | Description |
|---|
input | | CreateAccountRequest | CreateAccountInput | Account creation input (simplified) or full request object with policies |
Returns
Promise<CreateAccountResponse>
Promise resolving to created account information
Note: When passing AccountPolicies with signers, role defaults to ‘primary’ and provider defaults to ‘external’ if not specified.
Examples
const emailAccount = await gridClient.createAccount({
email: 'user@example.com'
});
const signerAccount = await gridClient.createAccount({
signer: 'BKKjHs7kKsWFm8GKuFz3HzNKBjH4K4HhjhwxDHrRfKjj'
});
const signerAccount = await gridClient.createAccount({
signers: [
{
address: 'BKKjHs7kKsWFm8GKuFz3HzNKBjH4K4HhjhwxDHrRfKjj',
permissions: ['CAN_INITIATE', 'CAN_VOTE']
}
],
threshold: 1,
timeLock: null,
adminAddress: null
});
Configuration
getConfig()
getConfig(): GridApiConfig;
Get client configuration
Returns
GridApiConfig
Example
const config = client.getConfig();
console.log(config.environment, config.baseUrl);
KYC Verification
requestKycLink()
requestKycLink(accountAddress, request): Promise<KycLinkResponse>;
Generates a link for Know Your Customer (KYC) identity verification.
Users complete the verification process through the provided link.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to associate with KYC |
request | RequestKycLinkRequest | KYC link request with verification requirements |
Returns
Promise<KycLinkResponse>
Promise resolving to KYC link response with verification URL
Example
const kycLink = await gridClient.requestKycLink(accountAddress, {
gridUserId: user.gridUserId,
type: 'individual',
email: 'user@example.com',
fullName: 'John Doe',
endorsements: [],
redirectUri: 'your-redirect-uri'
});
getKycStatus()
getKycStatus(accountAddress, kycId): Promise<KycStatusResponse>;
Get KYC verification status
Retrieves the current status of a KYC verification process, including
completion status, verification level, and any required actions.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address associated with KYC |
kycId | string | The KYC verification identifier |
Returns
Promise<KycStatusResponse>
Promise resolving to KYC status response
Example
const kycStatus = await gridClient.getKycStatus(accountAddress, kycId);
if (kycStatus.success) {
console.log(kycStatus.data.status); / 'pending', 'approved', 'rejected'
console.log(kycStatus.data.verificationLevel); / Verification tier achieved
}
Key Management
generateSessionSecrets()
generateSessionSecrets(): Promise<SessionSecrets>;
Generate session secrets for all supported providers
Returns
Promise<SessionSecrets>
Example
const sessionSecrets = await gridClient.generateSessionSecrets();
Other
extractSignableTransaction(transactionData): VersionedTransaction;
Extract a Solana VersionedTransaction ready to be signed using solana web3.js
Parameters
| Parameter | Type | Description |
|---|
transactionData | TransactionPayload | Grid transaction response containing the transaction |
Returns
VersionedTransaction
Deserialized VersionedTransaction ready for signing
Example
const preparedTx = await gridClient.prepareArbitraryTransaction(accountAddress, prepareRequest);
const signableTransaction = gridClient.extractSignableTransaction(preparedTx);
setExternallySignedTransaction()
setExternallySignedTransaction(transactionData, externallySignedTransaction): TransactionPayload;
Set an externally signed transaction into Grid transaction object so you can submit it via grid api.
Parameters
| Parameter | Type | Description |
|---|
transactionData | TransactionPayload | Original Grid transaction data |
externallySignedTransaction | VersionedTransaction | The signed VersionedTransaction |
Returns
TransactionPayload
Updated Grid transaction response with signed transaction data
Example
transaction.sign([externalSigner]);
const signedTxData = gridClient.setExternallySignedTransaction(
originalTxData,
transaction
);
getAccountBalances()
getAccountBalances(accountAddress, queryParams?): Promise<AccountBalancesResponse>;
Get account token balances
Retrieves the current token balances for an account, including both
native SOL and SPL token balances. Supports filtering and pagination.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to get balances for |
queryParams? | GetAccountBalancesQueryParams | Optional query parameters for filtering and pagination |
Returns
Promise<AccountBalancesResponse>
Promise resolving to account balances response
Example
const balances = await gridClient.getAccountBalances(accountAddress);
Passkey Management
getPasskeys()
getPasskeys(accountAddress): Promise<GetPasskeysResponse>;
Retrieves all passkeys for an account
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to get passkeys for |
Returns
Promise<GetPasskeysResponse>
Promise resolving to passkeys response with credential details
Example
const passkeys = await gridClient.getPasskeys(accountAddress);
addPasskey()
addPasskey(
accountAddress,
request,
queryParams?): Promise<AddPasskeyResponse>;
Registers a new passkey for an account.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to add the passkey to |
request | AddPasskeyRequest | Passkey registration request with credential data |
queryParams? | AddPasskeyQueryParams | Optional query parameters for the registration |
Returns
Promise<AddPasskeyResponse>
Promise resolving to passkey addition response
Example
const passkeyResponse = await gridClient.addPasskey(accountAddress, {
passkey: {
address: "2W6cUhpELHYhTi3Cn6SmHfVhJFKgqmUJLJ5V2DQNcaXE",
role: "secondary",
permissions: ["CAN_INITIATE", "CAN_VOTE", "CAN_EXECUTE"]
}
});
removePasskey()
removePasskey(
accountAddress,
passkeyAddress,
transactionSigners?,
queryParams?): Promise<RemovePasskeyResponse>;
Removes an existing passkey credential from an account, revoking its
ability to authorize transactions.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that owns the passkey |
passkeyAddress | string | The address of the passkey to remove |
transactionSigners? | string[] | - |
queryParams? | RemovePasskeyQueryParams | Optional query parameters for the removal |
Returns
Promise<RemovePasskeyResponse>
Promise resolving to passkey removal response
Example
const removeResponse = await gridClient.removePasskey(
accountAddress,
passkeyAddress
);
createPasskeyCredentials()
createPasskeyCredentials(params): Promise<PasskeyCredentialData>;
Initiates the WebAuthn credential creation process, prompting the user
to register a new passkey using their device’s authenticator (fingerprint,
face recognition, or security key).
Parameters
| Parameter | Type | Description |
|---|
params | PasskeyRequest | Passkey creation parameters including challenge and user info |
Returns
Promise<PasskeyCredentialData>
Promise resolving to credential data with public key and credential ID
Example
const credentialData = await gridClient.createPasskeyCredentials({
env: 'production',
challenge: 'base64-encoded-challenge',
slotNumber: '123',
sessionKey: 'session-public-key-base58',
expirationInSeconds: '3600',
appName: 'My App',
userId: 'user-identifier',
redirectUrl: 'your-redirect-url'
});
Note: You can use extractPasskeyCreateParams to extract the parameters from the URL.
getPasskeyCredentials()
getPasskeyCredentials(params, credentialData?): Promise<PasskeyAssertionResponse>;
Initiates the WebAuthn authentication process, prompting the user to
authenticate using their previously registered passkey.
Parameters
| Parameter | Type | Description |
|---|
params | PasskeyRequest | Passkey authentication parameters including challenge |
credentialData? | PasskeyCredentialData | Optional specific credential to authenticate with |
Returns
Promise<PasskeyAssertionResponse>
Promise resolving to assertion response with signature and authentication data
Example
const assertion = await gridClient.getPasskeyCredentials({
env: 'production',
challenge: 'base64-encoded-challenge',
slotNumber: '123',
sessionKey: 'session-public-key-base58',
expirationInSeconds: '3600',
appName: 'My App',
userId: 'user-identifier',
redirectUrl: 'your-redirect-url'
});
console.log(assertion.response.signature);
Note: You can use extractPasskeyAuthParams to extract the parameters from the URL.
extractPasskeyCreateParams(query): PasskeyRequest;
Parses URL search parameters to extract the necessary information
for passkey credential creation.
Parameters
| Parameter | Type | Description |
|---|
query | URLSearchParams | URLSearchParams object containing passkey creation parameters |
Returns
PasskeyRequest
Parsed passkey request object ready for credential creation
Example
const urlParams = new URLSearchParams(window.location.search);
const passkeyParams = gridClient.extractPasskeyCreateParams(urlParams);
const credentials = await gridClient.createPasskeyCredentials(passkeyParams);
extractPasskeyAuthParams(query): PasskeyRequest;
Parses URL search parameters to extract the necessary information
for passkey authentication.
Parameters
| Parameter | Type | Description |
|---|
query | URLSearchParams | URLSearchParams object containing passkey authentication parameters |
Returns
PasskeyRequest
Parsed passkey request object ready for authentication
Example
const urlParams = new URLSearchParams(window.location.search);
const authParams = gridClient.extractPasskeyAuthParams(urlParams);
const assertion = await gridClient.getPasskeyCredentials(authParams);
createPasskeyAccount()
createPasskeyAccount(params, environment): Promise<CreatePasskeyAccountResponse>;
Creates both a passkey account (externally signed account) and smart account in one call.
This combines the passkey creation ceremony with smart account initialization.
Creates a 1/1 smart account with the passkey having full permissions.
Parameters
| Parameter | Type | Description |
|---|
params | CreatePasskeyAccountRequest | Passkey account creation parameters including session key and authenticator response |
environment | string | Target environment (‘sandbox’ or ‘production’) |
Returns
Promise<CreatePasskeyAccountResponse>
Promise resolving to the created smart account details including passkey info
Example
const sessionKeyObject = {
key: sessionKeyPubkey,
expiration: Date.now() + 900000
};
const account = await gridClient.createPasskeyAccount({
sessionKey: sessionKeyObject,
slotNumber: 123,
authenticatorResponse: webauthnResponse,
adminAddress: 'admin-public-key',
memo: 'My passkey account'
}, 'sandbox');
console.log('Smart account address:', account.data.address);
console.log('Passkey account:', account.data.passkey.passkeyAccount);
console.log('Session key:', account.data.passkey.sessionKey);
Passkey Sessions
createPasskeySession()
createPasskeySession(params, environment): Promise<CreatePasskeySessionResponse>;
Initiates a new passkey authentication session, preparing the necessary
challenge and session data for WebAuthn authentication flow.
Parameters
| Parameter | Type | Description |
|---|
params | CreatePasskeySessionRequest | Passkey session creation parameters |
environment | string | Target environment (‘sandbox’ or ‘production’) |
Returns
Promise<CreatePasskeySessionResponse>
Promise resolving to passkey session creation response
Example
await gridClient.createPasskeySession({
action: 'create',
sessionKey: 'session-public-key-base58',
env: 'production',
}, 'production');
authorizePasskeySession()
authorizePasskeySession(params, environment): Promise<AuthorizePasskeySessionResponse>;
Submits passkey authentication data to authorize an existing session,
completing the WebAuthn authentication flow.
Parameters
| Parameter | Type | Description |
|---|
params | AuthorizePasskeySessionRequest | Passkey session authorization parameters with authentication data |
environment | string | Target environment (‘sandbox’ or ‘production’) |
Returns
Promise<AuthorizePasskeySessionResponse>
Promise resolving to session authorization response
Example
const authorization = await gridClient.authorizePasskeySession({
sessionKey: 'public-key-base58',
metaInfo: {
appName: 'My App',
redirectUrl: 'https:/myapp.com/callback'
},
baseUrl: 'base-url'
}, 'sandbox');
submitPasskeySession()
submitPasskeySession(params, environment): Promise<SubmitPasskeySessionResponse>;
Finalizes a passkey authentication session, generating the final
session tokens and account access credentials.
Parameters
| Parameter | Type | Description |
|---|
params | SubmitPasskeySessionRequest | Passkey session submission parameters |
environment | string | Target environment (‘sandbox’ or ‘production’) |
Returns
Promise<SubmitPasskeySessionResponse>
Promise resolving to session submission response with account details
Example
const result = await gridClient.submitPasskeySession({
authenticatorResponse: <attestationObject from getPasskeySession>,
sessionKey: 'public-key-base58',
ceremonyType: 'auth',
slotNumber: 123
}, 'sandbox');
findPasskeyAccount()
findPasskeyAccount(params, environment): Promise<FindPasskeyAccountResponse>;
Searches for an existing passkey account using credential information,
allowing users to recover access to their accounts.
Parameters
| Parameter | Type | Description |
|---|
params | FindPasskeyAccountRequest | Passkey account search parameters with credential data |
environment | string | Target environment (‘sandbox’ or ‘production’) |
Returns
Promise<FindPasskeyAccountResponse>
Promise resolving to found passkey account information
Example
const account = await gridClient.findPasskeyAccount({
sessionKey: 'public-key-base58',
authenticatorResponse: <attestationObject from getPasskeySession>
}, 'sandbox');
getPasskeyAccount()
getPasskeyAccount(passkeyAddress, environment): Promise<GetPasskeyAccountResponse>;
Retrieves detailed information about a specific passkey account,
including relying party ID, public key, and optional session key if not expired.
Parameters
| Parameter | Type | Description |
|---|
passkeyAddress | string | The passkey account address (Solana public key) to retrieve |
environment | string | Target environment (‘sandbox’ or ‘production’) |
Returns
Promise<GetPasskeyAccountResponse>
Promise resolving to passkey account details with relying party ID, public key, and optional session key
Example
const account = await gridClient.getPasskeyAccount(
'passkey-account-address',
'sandbox'
);
console.log(account.data.relyingPartyId);
console.log(account.data.pubkey);
if (account.data.sessionKey) {
console.log('Session key:', account.data.sessionKey.key);
console.log('Expires:', account.data.sessionKey.expiration);
}
Payment Processing
createPaymentIntent()
createPaymentIntent(accountAddress, request): Promise<CreatePaymentIntentResponse>;
Initiates a payment intent that allows users to deposit fiat currency
and receive cryptocurrency in their account. Handles the complete
fiat-to-crypto conversion process.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to receive the converted crypto |
request | CreatePaymentIntentRequest | Payment intent request with amount, currency, and payment method |
Returns
Promise<CreatePaymentIntentResponse>
Promise resolving to payment intent response with transaction details
Example
const paymentIntent = await gridClient.createPaymentIntent(accountAddress, {
amount: "100000",
source: {
account: accountAddress,
currency: "usdc"
},
destination: {
address: "3ciascNndLTBrDQXvs8nzZgWAiaL33tGM6fx3zzM7Fxt",
currency: "usdc"
}
});
console.log(paymentIntent.data.paymentUrl);
Proposal
createProposal()
createProposal(accountAddress, request): Promise<CreateProposalResponse>;
Create a proposal
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | Account address |
request | CreateProposalRequest | Create proposal request |
Returns
Promise<CreateProposalResponse>
Promise resolving to create proposal response
Example
const proposal = await client.createProposal(accountAddress, {
transaction: 'base64-encoded-solana-transaction',
signer: 'signer-pubkey',
rentPayer: 'rent-payer-pubkey'
});
voteProposal()
voteProposal(
accountAddress,
proposalAddress,
request): Promise<VoteProposalResponse>;
Vote on a proposal
Vote to approve, reject, or cancel a proposal on a smart account.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | Smart account address |
proposalAddress | string | Proposal address |
request | VoteProposalRequest | Vote proposal request containing signers and action |
Returns
Promise<VoteProposalResponse>
Promise resolving to vote proposal response with unsigned transaction
Example
const voteResult = await client.voteProposal(
accountAddress,
proposalAddress,
{
signers: ['signer-pubkey-1', 'signer-pubkey-2'],
action: 'approve'
}
);
console.log('Transaction:', voteResult.data.transaction);
console.log('Signers needed:', voteResult.data.transactionSigners);
executeProposal()
executeProposal(
accountAddress,
proposalAddress,
request): Promise<ExecuteProposalResponse>;
Execute a proposal
Execute an approved proposal on a smart account.
Important:
- Signer must have CAN_EXECUTE permission
- Proposal must be in Approved state
- Returns unsigned transaction with signatures
- The transactionSignatures array can contain multiple signatures
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | Smart account address |
proposalAddress | string | Proposal address |
request | ExecuteProposalRequest | Execute proposal request with signer |
Returns
Promise<ExecuteProposalResponse>
Promise resolving to execute proposal response with unsigned transaction
Example
const executeResult = await client.executeProposal(
accountAddress,
proposalAddress,
{ signer: 'executor-pubkey' }
);
console.log('Transaction:', executeResult.data.transaction);
console.log('Signatures:', executeResult.data.transactionSignatures);
Spending Limits
createSpendingLimit()
createSpendingLimit(smartAccountAddress, request): Promise<CreateSpendingLimitResponse>;
Creates a new spending limit.
Parameters
| Parameter | Type | Description |
|---|
smartAccountAddress | string | The account address to create spending limit for |
request | SpendingLimitRequest | Spending limit configuration including amount, token, and period |
Returns
Promise<CreateSpendingLimitResponse>
Promise resolving to transaction response for spending limit creation
Example
const spendingLimitTx = await gridClient.createSpendingLimit(accountAddress, {
amount: 10000000,
mint: '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU',
period: 'daily',
spendingLimitSigners: ['limit-signer-address']
});
updateSpendingLimit()
updateSpendingLimit(
accountAddress,
spendingLimitAddress,
request): Promise<SpendingLimitTransactionResponse>;
Modifies the parameters of an existing spending limit, such as the amount,
time period, or associated signers.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that owns the spending limit |
spendingLimitAddress | string | The address of the spending limit to update |
request | UpdateSpendingLimitRequest | Update request with new spending limit parameters |
Returns
Promise<SpendingLimitTransactionResponse>
Promise resolving to transaction response for the update
Example
const updateTx = await gridClient.updateSpendingLimit(
amount: "5000000",
spendingLimitSigners: ['signer-address']
);
deleteSpendingLimit()
deleteSpendingLimit(accountAddress, spendingLimitAddress): Promise<SpendingLimitTransactionResponse>;
Delete a spending limit
Removes an existing spending limit from an account, allowing unrestricted
spending for the associated token type.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that owns the spending limit |
spendingLimitAddress | string | The address of the spending limit to delete |
Returns
Promise<SpendingLimitTransactionResponse>
Promise resolving to transaction response for the deletion
Example
const deleteTx = await gridClient.deleteSpendingLimit(
accountAddress,
spendingLimitAddress
);
useSpendingLimit()
useSpendingLimit(
accountAddress,
spendingLimitAddress,
request): Promise<SpendingLimitTransactionResponse>;
Use a spending limit for a transaction
Utilizes an existing spending limit to authorize a transaction, automatically
checking that the transaction amount is within the limit constraints.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that owns the spending limit |
spendingLimitAddress | string | The address of the spending limit to use |
request | UseSpendingLimitRequest | Transaction request to authorize against the spending limit |
Returns
Promise<SpendingLimitTransactionResponse>
Promise resolving to transaction response for the authorized transaction
Example
const limitTx = await gridClient.useSpendingLimit(
accountAddress,
spendingLimitAddress,
{
amount: 500000000,
signerAddress: "signer-address",
recipientAddress: "recipient-address"
}
);
getSpendingLimit()
getSpendingLimit(accountAddress, spendingLimitAddress): Promise<SpendingLimitResponse>;
Retrieves a spending limit by its address
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that owns the spending limit |
spendingLimitAddress | string | The address of the spending limit to retrieve |
Returns
Promise<SpendingLimitResponse>
Promise resolving to spending limit data
Example
const spendingLimit = await gridClient.getSpendingLimit(
accountAddress,
spendingLimitAddress
);
console.log(spendingLimit.amount);
console.log(spendingLimit.remainingAmount);
getSpendingLimits()
getSpendingLimits(accountAddress): Promise<SpendingLimitsResponse>;
Retrieves all spending limits for an account
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to get spending limits for |
Returns
Promise<SpendingLimitsResponse>
Promise resolving to array of spending limit data
Example
const limits = await gridClient.getSpendingLimits(accountAddress);
limits.forEach(limit => {
console.log(`Limit: ${limit.amount}, Remaining: ${limit.remainingAmount}`);
});
Standing Orders
createStandingOrder()
createStandingOrder(accountAddress, request): Promise<CreateStandingOrderResponse>;
Create a standing order.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that will make the recurring payments |
request | CreateStandingOrderRequest | Standing order request with payment details and schedule |
Returns
Promise<CreateStandingOrderResponse>
Promise resolving to standing order creation response
Example
const standingOrder = await gridClient.createStandingOrder(accountAddress, {
amount: "500000",
gridUserId: "grid-user-id",
source: {
account: "source-address",
currency: "usdc"
},
destination: {
address: "destination-address",
currency: "usdc"
},
frequency: "weekly",
startDate: "2024-12-02T10:00:00Z",
endDate: "2025-12-31T23:59:59Z"
});
getStandingOrders()
getStandingOrders(accountAddress, queryParams?): Promise<StandingOrdersResponse>;
Retrieves all standing orders associated with an account, including
active, paused, and completed recurring payment schedules.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to get standing orders for |
queryParams? | GetStandingOrdersQueryParams | Optional query parameters for filtering and pagination |
Returns
Promise<StandingOrdersResponse>
Promise resolving to standing orders response
Example
const standingOrders = await gridClient.getStandingOrders(accountAddress);
getStandingOrder()
getStandingOrder(accountAddress, standingOrderId): Promise<StandingOrderResponse>;
Retrieves detailed information about a specific standing order,
including its current status, execution history, and next payment date.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that owns the standing order |
standingOrderId | string | The unique identifier of the standing order |
Returns
Promise<StandingOrderResponse>
Promise resolving to standing order details response
Example
const order = await gridClient.getStandingOrder(accountAddress, orderId);
Trade Smart Transactions
createTradeSmartTransaction()
createTradeSmartTransaction(accountAddress, request): Promise<CreateTradeSmartTransactionResponse>;
Create a trade policy with spending limits and authorized signers.
Note: Policies define allowed tokens, spending limits per period, and authorized signers for automated trading.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | Smart account address |
request | CreateTradeSmartTransactionRequest | Policy configuration with signers, rules, and spending constraints |
Returns
Promise<CreateTradeSmartTransactionResponse>
Policy address and transaction to sign
Example
const response = await client.createTradeSmartTransaction(accountAddress, {
policies: {
signers: [{ address: 'XXXxx...', permissions: ['CAN_INITIATE', 'CAN_VOTE', 'CAN_EXECUTE'] }],
threshold: 1
},
rules: {
allowedInputs: [{
mint: 'So11111111111111111111111111111111111111112',
allowance: { amount: '1000000000', cadence: 'Daily' }
}],
allowedOutputs: ['EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'],
maxSlippageBps: 100,
feesBps: 10,
venue: 'jupiter'
}
});
getTradeSmartTransactionQuote()
getTradeSmartTransactionQuote(
accountAddress,
smartTransactionAddress,
request): Promise<TradeSmartTransactionQuoteResponse>;
Get a trade quote validated against policy constraints.
Note: Quote checks spending limits and validates input/output tokens before returning price.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | Smart account address |
smartTransactionAddress | string | Policy address |
request | TradeSmartTransactionQuoteRequest | Quote parameters with venue, tokens, amount, and slippage |
Returns
Promise<TradeSmartTransactionQuoteResponse>
Validated quote from trading venue
Example
const quote = await client.getTradeSmartTransactionQuote(
accountAddress,
smartTransactionAddress,
{
venue: 'jupiter',
fromMint: 'So11111111111111111111111111111111111111112',
toMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: 100000000,
slippageBps: 50
}
);
prepareTradeSmartTransaction()
prepareTradeSmartTransaction(
accountAddress,
smartTransactionAddress,
request,
queryParams?): Promise<PrepareTradeSmartTransactionResponse>;
Prepare a trade transaction with policy validation.
Note: Validates against spending limits and allowed tokens before building transaction.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | Smart account address |
smartTransactionAddress | string | Policy address |
request | PrepareTradeSmartTransactionRequest | Trade details or pre-fetched quote |
queryParams? | PrepareTradeSmartTransactionQueryParams | Optional debug mode for simulation logs |
Returns
Promise<PrepareTradeSmartTransactionResponse>
Prepared transaction with KMS payloads for signing
Example
const tx = await client.prepareTradeSmartTransaction(
accountAddress,
smartTransactionAddress,
{
tradeArgs: {
type: 'arguments',
input: 'So11111111111111111111111111111111111111112',
output: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: 100000000,
slippageBps: 50,
feeBps: 10
}
}
);
getTradeSmartTransaction()
getTradeSmartTransaction(accountAddress, smartTransactionAddress): Promise<GetTradeSmartTransactionResponse>;
Retrieve policy details and current spending limit status.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | Smart account address |
smartTransactionAddress | string | Policy address |
Returns
Promise<GetTradeSmartTransactionResponse>
Policy configuration and tradable assets with remaining allowances
Example
const result = await client.getTradeSmartTransaction(accountAddress, smartTransactionAddress);
Transaction Processing
prepareArbitraryTransaction()
prepareArbitraryTransaction(
accountAddress,
request,
queryParams?): Promise<TransactionResponse>;
Prepares any Solana transaction for signing by adding necessary account
metadata, fee calculations, and smart account integration.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address that will sign the transaction |
request | PrepareArbitraryTransactionRequest | Transaction preparation request with the raw transaction |
queryParams? | PrepareArbitraryTransactionQueryParams | Optional query parameters for transaction preparation |
Returns
Promise<TransactionResponse>
Promise resolving to prepared transaction response ready for signing
Example
const preparedTx = await gridClient.prepareArbitraryTransaction(accountAddress, {
transaction: 'base64-encoded-solana-transaction'
});
const signedTx = await gridClient.sign({
sessionSecrets: sessionSecrets,
transactionPayload: preparedTx
});
Transaction Signing
sign()
sign(request): Promise<TransactionResult>;
Automatically selects the appropriate authentication provider based on the
session context and available session secrets.
Parameters
| Parameter | Type | Description |
|---|
request | SignRequest | Sign request containing transaction payload and session secrets |
Returns
Promise<TransactionResult>
Promise resolving to transaction result with signatures and metadata
Example
const authResult = await gridClient.completeAuth(payload);
const preparedTx = await gridClient.prepareArbitraryTransaction(accountAddress, {
transaction: 'base64-encoded-transaction'
});
const signResult = await gridClient.sign({
sessionSecrets: sessionSecrets,
transactionPayload: preparedTx,
session: authResult.authentication
});
signAndSend()
signAndSend(request): Promise<TransactionSubmissionResponse>;
Sign and send a transaction. Automatically selects the appropriate authentication provider based on the
session context and available session secrets
Parameters
| Parameter | Type | Description |
|---|
request | SignAndSendRequest | Sign and send request containing transaction payload and session secrets |
Returns
Promise<TransactionSubmissionResponse>
Promise resolving to transaction submission result with blockchain signature
Example
const authResult = await gridClient.completeAuth(payload);
const preparedTx = await gridClient.prepareArbitraryTransaction(accountAddress, {
transaction: 'base64-encoded-transaction'
});
const result = await gridClient.signAndSend({
sessionSecrets: sessionSecrets,
transactionPayload: preparedTx,
session: authResult.authentication,
address: accountAddress
});
send()
send(request): Promise<TransactionSubmissionResponse>;
Submits a previously signed transaction to the Solana blockchain through
the Grid API.
Parameters
| Parameter | Type | Description |
|---|
request | SendTransactionRequest | Send request containing the signed transaction and account address |
Returns
Promise<TransactionSubmissionResponse>
Promise resolving to transaction submission result with signature
Example
const signedTx = await gridClient.sign({ ... });
const result = await gridClient.send({
signedTransactionPayload: signedTx,
address: 'account-address'
});
Utilities
getSessionKeyObject()
getSessionKeyObject(sessionKeyString, expirationInSeconds): SessionKey;
Helper function to create session key object from string and expiration
Parameters
| Parameter | Type | Description |
|---|
sessionKeyString | string | Base58-encoded session key string |
expirationInSeconds | string | Expiration time as a string (seconds since epoch) |
Returns
SessionKey
SessionKey object with decoded key bytes and parsed expiration
Example
const sessionKey = gridClient.getSessionKeyObject(
'base58-encoded-key',
'900'
);
getEnvironment()
getEnvironment(): "sandbox" | "production";
Get the current environment configuration
Returns the environment the SDK is configured to use.
This is useful for determining which network (devnet/mainnet) operations are targeting.
Returns
"sandbox" | "production"
The current environment (‘sandbox’ for devnet, ‘production’ for mainnet)
Example
const env = gridClient.getEnvironment();
console.log(env); / 'sandbox' or 'production'
Virtual Accounts
requestVirtualAccount()
requestVirtualAccount(accountAddress, request): Promise<VirtualAccountResponse>;
Creates a virtual bank account that allows users to receive fiat deposits
which are automatically converted to cryptocurrency in their Grid account.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to associate with the virtual account |
request | RequestVirtualAccountRequest | Virtual account request with banking details and preferences |
Returns
Promise<VirtualAccountResponse>
Promise resolving to virtual account response with banking details
Example
const virtualAccount = await gridClient.requestVirtualAccount(accountAddress, {
gridUserId: 'grid-user-id',
currency: 'usd' as const
});
getVirtualAccounts()
getVirtualAccounts(accountAddress, queryParams?): Promise<VirtualAccountsResponse>;
Retrieves all virtual bank accounts associated with a Grid account,
including their status, balances, and transaction history.
Parameters
| Parameter | Type | Description |
|---|
accountAddress | string | The account address to get virtual accounts for |
queryParams? | GetVirtualAccountsQueryParams | Optional query parameters for filtering and pagination |
Returns
Promise<VirtualAccountsResponse>
Promise resolving to virtual accounts response
Example
const virtualAccounts = await gridClient.getVirtualAccounts(accountAddress);