Actions

chevron-rightgetAccounthashtag
const account = getAccount();

export type Account = {
  triaName: string | null;
  evm: {
    address: string;
  };
};
chevron-rightdisconnecthashtag
await disconnect();
chevron-rightsignMessagehashtag
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;
};
chevron-rightsendhashtag
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;
};
chevron-rightreadContracthashtag
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;
};
chevron-rightwriteContracthashtag
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;
};
chevron-rightsendNfthashtag
chevron-rightencrypthashtag
chevron-rightdecrypthashtag
chevron-rightapprovehashtag
chevron-rightcheckTokenAllowancehashtag
chevron-rightbroadcastTransactionhashtag
chevron-rightgetBridgeQuotehashtag
chevron-rightcreateBridgeTxnhashtag
chevron-rightcancelBridgeTxnhashtag
chevron-rightcreateSolanaCalldatahashtag

Refer How to create Debridge Solana Calldata to understand better.

chevron-rightsignAndSendTransaction [SOLANA]hashtag

Types

chevron-rightChainDatahashtag
chevron-rightBridgeParamshashtag

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