Actions

getAccount
const account = getAccount();

export type Account = {
  triaName: string | null;
  evm: {
    address: string;
  };
};
disconnect
await disconnect();
signMessage
signMessage(
  calldata: SignMessageParams,
  dappDetails?: dappDetails,
  authUrl: string = triaAuthUrl,
  environment: ENV = 'mainnet'
): Promise<StringDataResponse>;

type SignMessageParams = {
  message: string; // eg. Sign in with Tria
  chainName: string; // eg. POLYGON
};

type dappDetails = {
  dappDomain?: string;
  dappLogo?: string;
};

export type StringDataResponse = {
  success: boolean;
  data?: string;
  message?: string;
  error?: any;
};
send
send(
  calldata: SendParams,
  dappDetails?: dappDetails,
  authUrl: string = triaAuthUrl,
  environment: ENV = 'mainnet'
): Promise<TxnResponse>

type SendParams = {
  amount: number;
  recepientAddress: string;
  chainName: string;
  tokenAddress?: string;
};

export type dappDetails = {
  dappDomain?: string;
  dappLogo?: string;
};

type TxnResponse {
  success: boolean;
  data?: TxnDataResponse;
  message?: string;
  error?: any;
}

type TxnDataResponse = {
  txnId: string;
  viewInExplorer: string;
  wait?: Function;
};
readContract
readContract(
  params: ReadContractParams
): Promise<ReadContractResponse>

type ReadContractParams = {
  chainName: string;
  contractDetails: ContractDetails;
};

type ContractDetails = {
  contractAddress: string;
  abi: Object[];
  functionName: string;
  args: any[];
  value?: number;
};

type ReadContractResponse = {
  success: boolean;
  data?: any;
  message?: string;
  error?: any;
};
writeContract
writeContract(
  calldata: WriteContractParams,
  dappDetails?: dappDetails,
  authUrl: string = triaAuthUrl,
  environment: ENV = 'mainnet'
): Promise<TxnResponse>

type WriteContractParams = {
  chainName: string;
  payToken?: {
    tokenAddress: string;
    amount: number;
  };
  contractDetails: ContractDetails;
};

type ContractDetails = {
  contractAddress: string;
  abi: Object[];
  functionName: string;
  args: any[];
  value?: number;
  enableTriaName?: boolean; // true if wanna pass triaName in args[]
};

export type dappDetails = {
  dappDomain?: string;
  dappLogo?: string;
};

type TxnResponse {
  success: boolean;
  data?: TxnDataResponse;
  message?: string;
  error?: any;
}

type TxnDataResponse = {
  txnId: string;
  viewInExplorer: string;
  wait?: Function;
};
sendNft
encrypt
decrypt
approve
checkTokenAllowance
broadcastTransaction
getBridgeQuote
createBridgeTxn
cancelBridgeTxn
createSolanaCalldata

Refer How to create Debridge Solana Calldata to understand better.

signAndSendTransaction [SOLANA]

Types

ChainData
BridgeParams

Steps to integrate bridge:

  1. Use the getQuoteBridge function to get the quote for erc20 tokens and their allowance target and value.

  2. Use this this allowance target and value, to checkTokenAllowance, and approve for erc20 token

  3. Use the createBridgeTxn to get the txn object for the bridge txn

  4. Use the broadcastTransaction function to sign and send this txn object on-chain.

  5. To cancel a txn, use the cancelBridgeTxn with the orderId returned in the createBridgeTxn response

Last updated