Skip to main content

Interfaces

CreateAccountOptions

Defined in: client/solana/solana.types.ts:59 Options for creating a Solana account.

Properties

accountPolicy?
optional accountPolicy: string;
Defined in: client/solana/solana.types.ts:63 The policy ID to apply to the account.
idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:65 The idempotency key.
name?
optional name: string;
Defined in: client/solana/solana.types.ts:61 The name of the account.

ExportAccountOptions

Defined in: client/solana/solana.types.ts:71 Options for exporting a Solana account.

Properties

address?
optional address: string;
Defined in: client/solana/solana.types.ts:73 The address of the account.
idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:77 The idempotency key.
name?
optional name: string;
Defined in: client/solana/solana.types.ts:75 The name of the account.

GetAccountOptions

Defined in: client/solana/solana.types.ts:83 Options for getting a Solana account.

Properties

address?
optional address: string;
Defined in: client/solana/solana.types.ts:85 The address of the account.
name?
optional name: string;
Defined in: client/solana/solana.types.ts:87 The name of the account.

GetOrCreateAccountOptions

Defined in: client/solana/solana.types.ts:93 Options for getting a Solana account.

Properties

name
name: string;
Defined in: client/solana/solana.types.ts:95 The name of the account.

ImportAccountOptions

Defined in: client/solana/solana.types.ts:171 Options for importing a Solana account.

Properties

encryptionPublicKey?
optional encryptionPublicKey: string;
Defined in: client/solana/solana.types.ts:173 The public RSA key used to encrypt the private key when importing a Solana account.
idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:177 The idempotency key.
name?
optional name: string;
Defined in: client/solana/solana.types.ts:175 The name of the account.
privateKey
privateKey: string | Uint8Array<ArrayBufferLike>;
Defined in: client/solana/solana.types.ts:179 The private key of the account - can be a base58 encoded string or raw bytes.

ListAccountsOptions

Defined in: client/solana/solana.types.ts:113 Options for listing Solana accounts.

Properties

pageSize?
optional pageSize: number;
Defined in: client/solana/solana.types.ts:115 The page size.
pageToken?
optional pageToken: string;
Defined in: client/solana/solana.types.ts:117 The page token.

ListAccountsResult

Defined in: client/solana/solana.types.ts:123 The result of listing Solana accounts.

Properties

accounts
accounts: {
  requestFaucet: (options: Omit<RequestFaucetOptions, "address">) => Promise<SignatureResult>;
  sendTransaction: (options: Omit<SendTransactionOptions, "address">) => Promise<SendTransactionResult>;
  signMessage: (options: Omit<SignMessageOptions, "address">) => Promise<SignatureResult>;
  signTransaction: (options: Omit<SignTransactionOptions, "address">) => Promise<SignTransactionResult>;
  transfer: (options: Omit<TransferOptions, "from">) => Promise<SignatureResult>;
}[];
Defined in: client/solana/solana.types.ts:125 The accounts.
requestFaucet()
requestFaucet: (options: Omit<RequestFaucetOptions, "address">) => Promise<SignatureResult>;
Requests funds from a Solana faucet.
Parameters
options
Omit<RequestFaucetOptions, "address"> Parameters for requesting funds from the Solana faucet.
Returns
Promise<SignatureResult> A promise that resolves to the transaction hash.
Example
// Create a Solana account
const account = await cdp.solana.createAccount();

// Request funds from the Solana faucet
const result = await account.requestFaucet({
  token: "sol",
});
sendTransaction()
sendTransaction: (options: Omit<SendTransactionOptions, "address">) => Promise<SendTransactionResult>;
Sends a transaction.
Parameters
options
Omit<SendTransactionOptions, "address"> Parameters for sending the transaction.
Returns
Promise<SendTransactionResult> A promise that resolves to the transaction signature.
Example
// Create a Solana account
const account = await cdp.solana.createAccount();

// Build your transaction using @solana/kit
import {
  address as solanaAddress,
  appendTransactionMessageInstructions,
  compileTransaction,
  createNoopSigner,
  createSolanaRpc,
  createTransactionMessage,
  getBase64EncodedWireTransaction,
  pipe,
  setTransactionMessageFeePayer,
  setTransactionMessageLifetimeUsingBlockhash,
} from "@solana/kit";
import { getTransferSolInstruction } from "@solana-program/system";

const rpc = createSolanaRpc("https://api.devnet.solana.com");
const { value: { blockhash, lastValidBlockHeight } } = await rpc.getLatestBlockhash().send();

const txMsg = pipe(
  createTransactionMessage({ version: 0 }),
  (tx) => setTransactionMessageFeePayer(solanaAddress(account.address), tx),
  (tx) => setTransactionMessageLifetimeUsingBlockhash(
    { blockhash, lastValidBlockHeight },
    tx,
  ),
  (tx) => appendTransactionMessageInstructions([
    getTransferSolInstruction({
      source: createNoopSigner(solanaAddress(account.address)),
      destination: solanaAddress("3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE"),
      amount: 10000n,
    }),
  ], tx),
);

// Base64 encode the compiled transaction
const transaction = getBase64EncodedWireTransaction(compileTransaction(txMsg));

// Send the transaction via the CDP API
const { transactionSignature } = await account.sendTransaction({
  transaction,
});
signMessage()
signMessage: (options: Omit<SignMessageOptions, "address">) => Promise<SignatureResult>;
Signs a message.
Parameters
options
Omit<SignMessageOptions, "address"> Parameters for signing the message.
Returns
Promise<SignatureResult> A promise that resolves to the signature.
Example
// Create a Solana account
const account = await cdp.solana.createAccount();

// Sign a message
const { signature } = await account.signMessage({
  message: "Hello, world!",
});
signTransaction()
signTransaction: (options: Omit<SignTransactionOptions, "address">) => Promise<SignTransactionResult>;
Signs a transaction.
Parameters
options
Omit<SignTransactionOptions, "address"> Parameters for signing the transaction.
Returns
Promise<SignTransactionResult> A promise that resolves to the signature.
Example
// Create a Solana account
const account = await cdp.solana.createAccount();

// Build your transaction using @solana/kit
import {
  address as solanaAddress,
  appendTransactionMessageInstructions,
  compileTransaction,
  createNoopSigner,
  createSolanaRpc,
  createTransactionMessage,
  getBase64EncodedWireTransaction,
  pipe,
  setTransactionMessageFeePayer,
  setTransactionMessageLifetimeUsingBlockhash,
} from "@solana/kit";
import { getTransferSolInstruction } from "@solana-program/system";

const rpc = createSolanaRpc("https://api.devnet.solana.com");
const { value: { blockhash, lastValidBlockHeight } } = await rpc.getLatestBlockhash().send();

const txMsg = pipe(
  createTransactionMessage({ version: 0 }),
  (tx) => setTransactionMessageFeePayer(solanaAddress(account.address), tx),
  (tx) => setTransactionMessageLifetimeUsingBlockhash(
    { blockhash, lastValidBlockHeight },
    tx,
  ),
  (tx) => appendTransactionMessageInstructions([
    getTransferSolInstruction({
      source: createNoopSigner(solanaAddress(account.address)),
      destination: solanaAddress("3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE"),
      amount: 10000n,
    }),
  ], tx),
);

// Base64 encode the compiled transaction
const transaction = getBase64EncodedWireTransaction(compileTransaction(txMsg));

// Sign the transaction via the CDP API
const { signedTransaction } = await account.signTransaction({
  transaction,
});
transfer()
transfer: (options: Omit<TransferOptions, "from">) => Promise<SignatureResult>;
Transfers SOL or SPL tokens between accounts
Parameters
options
Omit<TransferOptions, "from"> Parameters for the transfer.
Returns
Promise<SignatureResult> A promise that resolves to the transaction signature, which can be used to wait for the transaction result.
Example
const account = await cdp.solana.getAccount({ name: "Account" });

const { signature } = await account.transfer({
  token: "sol",
  amount: 5_000_000_000n, // 5 SOL in lamports
  to: "3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE",
  network: "devnet",
});
nextPageToken?
optional nextPageToken: string;
Defined in: client/solana/solana.types.ts:129 The token for the next page of accounts, if any.

ListTokenBalancesOptions

Defined in: client/solana/solana.types.ts:185 Options for listing Solana token balances.

Properties

address
address: string;
Defined in: client/solana/solana.types.ts:187 The address of the account.
network?
optional network: ListSolanaTokenBalancesNetwork;
Defined in: client/solana/solana.types.ts:189 The network to list token balances for.
pageSize?
optional pageSize: number;
Defined in: client/solana/solana.types.ts:191 The page size.
pageToken?
optional pageToken: string;
Defined in: client/solana/solana.types.ts:193 The page token.

ListTokenBalancesResult

Defined in: client/solana/solana.types.ts:247 The result of listing Solana token balances.

Properties

balances
balances: SolanaTokenBalance[];
Defined in: client/solana/solana.types.ts:249 The token balances.
nextPageToken?
optional nextPageToken: string;
Defined in: client/solana/solana.types.ts:254 The next page token to paginate through the token balances. If undefined, there are no more token balances to paginate through.

RequestFaucetOptions

Defined in: client/solana/solana.types.ts:135 Options for requesting funds from a Solana faucet.

Properties

address
address: string;
Defined in: client/solana/solana.types.ts:137 The address of the account.
idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:141 The idempotency key.
token
token: "sol" | "usdc";
Defined in: client/solana/solana.types.ts:139 The token to request funds for.

SendTransactionOptions

Defined in: client/solana/solana.types.ts:199 Options for sending a Solana transaction.

Properties

idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:207 The idempotency key.
network
network: SendSolanaTransactionBodyNetwork;
Defined in: client/solana/solana.types.ts:201 The network to send the transaction to.
transaction
transaction: string;
Defined in: client/solana/solana.types.ts:203 The base64 encoded transaction to send.
useCdpSponsor?
optional useCdpSponsor: boolean;
Defined in: client/solana/solana.types.ts:205 Whether CDP should sponsor the transaction fees.

SignatureResult

Defined in: client/solana/solana.types.ts:51 A Solana signature result.

Properties

signature
signature: string;
Defined in: client/solana/solana.types.ts:53 The signature.

SignMessageOptions

Defined in: client/solana/solana.types.ts:147 Options for signing a Solana message.

Properties

address
address: string;
Defined in: client/solana/solana.types.ts:149 The address of the account.
idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:153 The idempotency key.
message
message: string;
Defined in: client/solana/solana.types.ts:151 The message to sign.

SignTransactionOptions

Defined in: client/solana/solana.types.ts:159 Options for signing a Solana transaction.

Properties

address
address: string;
Defined in: client/solana/solana.types.ts:161 The address of the account.
idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:165 The idempotency key.
transaction
transaction: string;
Defined in: client/solana/solana.types.ts:163 The base64 encoded transaction to sign.

SolanaToken

Defined in: client/solana/solana.types.ts:225

Properties

mintAddress
mintAddress: string;
Defined in: client/solana/solana.types.ts:227 The token address.
name?
optional name: string;
Defined in: client/solana/solana.types.ts:229 The token name.
symbol?
optional symbol: string;
Defined in: client/solana/solana.types.ts:231 The token symbol.

SolanaTokenAmount

Defined in: client/solana/solana.types.ts:218

Properties

amount
amount: bigint;
Defined in: client/solana/solana.types.ts:220 The amount of the token.
decimals
decimals: number;
Defined in: client/solana/solana.types.ts:222 The number of decimals in the token.

SolanaTokenBalance

Defined in: client/solana/solana.types.ts:237 A Solana token balance.

Properties

amount
amount: SolanaTokenAmount;
Defined in: client/solana/solana.types.ts:239 The amount of the token.
token
token: SolanaToken;
Defined in: client/solana/solana.types.ts:241 The token.

TransactionResult

Defined in: client/solana/solana.types.ts:213 The result of sending a Solana transaction.

Properties

signature
signature: string;
Defined in: client/solana/solana.types.ts:215 The signature of the transaction base58 encoded.

UpdateSolanaAccountOptions

Defined in: client/solana/solana.types.ts:101 Options for creating a SOL server account.

Properties

address
address: string;
Defined in: client/solana/solana.types.ts:103 The address of the account.
idempotencyKey?
optional idempotencyKey: string;
Defined in: client/solana/solana.types.ts:107 The idempotency key.
update
update: UpdateSolanaAccountBody;
Defined in: client/solana/solana.types.ts:105 The updates to apply to the account

Type Aliases