All directly invoked methods return the following type:
export type ResultType = {
code: number;
message?: string;
result?: any;
}Explanation:
code:0indicates success; any other value indicates failure.message: Empty if successful; contains error info if failed.result: Contains a value if successful; empty if failed.
Encryption method, enum type:
export enum KEYPAIR_TYPE {
ECC = 1,
}Cross-chain bridge protocol, enum type:
export enum BRIDGE_PTOTOCOL {
CCIP = 1,
}Parameters required for the send() method:
export type SendPayload = {
from?: string;
cipherText?: string;
amount: number;
token: {
address: string;
decimal?: number;
};
receive: {
receipt: string;
createSA?: boolean; // default: true;
};
bridge?: {
chain: number;
protocol: BRIDGE_PTOTOCOL;
token?: string;
};
};Field Descriptions:
| Field Name | Type | Required | Description |
|---|---|---|---|
| from | string | No | Defaults to empty. If empty, the transaction is initiated from an EOA wallet. If filled, the transaction is initiated from the SA address of the EOA wallet. |
| cipherText | string | No | Defaults to empty. Required if from is not empty. |
| amount | number | Yes | Amount to send. |
| token.address | string | Yes | Token address. If it is a native token, use "0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEETH". For other tokens, provide the token address. |
| token.decimal | number | No | Token decimals. Required if it's a non-native token. |
| receive.receipt | string | Yes | Receiver's address. Can be a standard wallet address, ENS, CNS, or SA address. |
| receive.createSA | boolean | No | Whether to create an SA. If receive.receipt is a standard wallet/ENS/CNS, and createSA is true, it targets EOA(SA); if false, it targets EOA. Ignored if SA. |
| bridge.chain | number | Yes | Receiver’s chainId (decimal). If equal to the signer’s chainId, it’s not cross-chain; otherwise, it is a cross-chain transfer. |
| bridge.protocol | number | Yes | Bridge protocol, e.g., CCIP, etc. |
| bridge.token | string | No | Token address specified by the receiver. |
import { MindSAP } from "mind-sap-sdk";
const mindSAP = new MindSAP();const response: ResultType = await mindSAP.send(signer, payload);signer: The signer obtained after connecting the wallet.
Example:
import { Web3Provider } from "@ethersproject/providers";
const [connectedWallet] = await onboard.connectWallet();
const provider = new Web3Provider(connectedWallet.provider);
const signer = provider.getSigner();payload: The parameter passed tosend, determines different scenarios based on fields. Field details: SendPayload
const response: ResultType = await mindSAP.registry(signer);signer: The signer obtained after connecting the wallet.
Checks whether an address is already registered.
Parameter can be a signer, wallet address, ENS, or CNS.
const response: ResultType = await mindSAP.isRegistry(signer | walletAddress);signer: The signer obtained after connecting the wallet.
const response: ResultType = await mindSAP.scan(signer);signer: The signer obtained after connecting the wallet.
const response: ResultType = await mindSAP.getBalance(signer, tokenAddress?, SA?);signer: The signer obtained after connecting the wallet.tokenAddress: Address of the token to check balance for. If empty, returns native token balance.SA: If provided, returns the balance of the SA address; otherwise, returns the signer’s balance.