Solana Wallet

Solana wallet controller for dapp side created any type of transactions

npm i @tria-sdk/web@4.2.27
Create an instance
const solanaWallet = new SolanaWallet({
    baseUrl: "https://dev.tria.so", // or staging for old infra
    walletType: {embedded: true},
    chainName: "SOLANA", // or "SOLANA-DEVNET" // can later add SOLANA-TESTNET too
});
signAndSendTransaction ⛽️
signAndSendTransaction({
    transaction: Transaction,
    gas: Gas
}): Promise<TxnResponse>;
export type TxnResponse = {
    success: boolean;
    data?: {
        txnId: string;
        viewInExplorer: string;
        wait: Function;
    };
    message?: string;
    error?: any;
};
getInstructions
getInstructions({ transaction: Transaction }): TxnInstruction[]
export type TxnInstruction = {
    name?: string;
    programId: string;
    data: string;
};
getEstimatedFee
getEstimatedFee({ transaction: Transaction }): Promise<FeeResponse>
export type FeeResponse = {
    success: boolean;
    fee?: {
        eth: string;
        usd?: string;
    };
    message?: string;
    error?: any;
};
estimateSolBalanceChange
estimateSolBalanceChange({ transaction: Transaction }): Promise<number | undefined> 

Note: This is only applicable in Tria's v2 internal infra, as in old infra.

How it works?

  • This can be used for any transaction created by the dapp on Solana, and wants to get signed via user's Tria wallet.

  • Passing the gas param in the signAndSendTxn function will cut the gas in any token, like USDC, SOL, etc., hence no dependency on SOL native tokens now to make txns

    • This was made possible because of Shyft Txn Relayer, which provides a feePayer to add to any Solana transactions

    • On the basis of the gas estimated, Tria's Solana feePayer will sponsor all that gas in SOL, and the user just has to pay in any token they prefer on Solana.

    • These transactions internally are partially signed by the user's key, as well as by the feePayer for paying the SOL fees.

About WalletController and FeeController

  • You can still keep using the WalletController and FeeController for Solana

    • for send, sendNft

    • for getSendFee, getSendNftFee

  • Only add the new popup for enabling any Solana transaction via SolanaWallet controller

Last updated