钱包标准
方法 | 参数 | 返回值 | 描述 |
---|---|---|---|
connect | { contractId?: string } | Promise<{ accountId: string; publicKey: string }> | 连接到钱包并返回账户信息 |
disconnect | 无 | Promise<void> | 断开钱包连接 |
isSignedIn | 无 | boolean | 检查用户是否已登录 |
getAccountId | 无 | string | 获取当前账户 ID |
account | 无 | ConnectedWalletAccount | null | 获取当前账户对象 |
signMessage | { message: string; recipient: string; nonce: Buffer } | Promise<{ signature: string }> | 签名消息 |
signAndSendTransaction | { signerId?: string; receiverId: string; actions: Action[] } | Promise<FinalExecutionOutcome> | 签名并发送交易 |
signAndSendTransactions | { transactions: Transaction[] } | Promise<FinalExecutionOutcome[]> | 签名并发送多个交易 |
连接 Bitget 钱包
连接
连接到 NEAR 钱包。
参数
contractId
- string (可选): 合约 ID
返回值
interface ConnectResult {
accountId: string
publicKey: string
}
检查连接状态
检查用户是否已登录。
返回值
boolean
: 是否已登录
用法
const isSignedIn = provider.isSignedIn()
试一试
Loading live editor...
断开连接
断开钱包连接。
用法
await provider.disconnect()
试一试
Loading live editor...
用法
const result = await provider.connect({
contractId: 'example.near',
})
试一试
Loading live editor...
账户方法
Provider
const provider = window.bitkeep.near
获取账户 ID
获取当前连接的账户 ID。
返回值
string
: 账户 ID
用法
const accountId = provider.getAccountId()
试一试
Loading live editor...
获取公钥
获取与用户账户关联的公钥
使用
window.bitkeep.getPublicKey()
试一试
Loading live editor...
交易
签名并发送单词交易
签名并发送单个交易。
参数
signerId
- string (可选): 签名者 IDreceiverId
- string: 接收者 IDactions
- Action[]: 交易动作数组
返回值
interface FinalExecutionOutcome {
status: ExecutionStatus
transaction: any
transaction_outcome: ExecutionOutcomeWithId
receipts_outcome: ExecutionOutcomeWithId[]
}
用法
const result = await provider.signAndSendTransaction({
receiverId: 'example.near',
actions: [
{
type: 'Transfer',
params: {
deposit: '1000000000000000000000000', // 1 NEAR
},
},
],
})
签名并发送多个交易
签名并发送多个交易。
参数
transactions
- Transaction[]: 交易数组
返回值
Promise<FinalExecutionOutcome[]>
: 交易结果数组
用法
const results = await provider.signAndSendTransactions({
transactions: [
{
receiverId: 'example1.near',
actions: [
/* actions */
],
},
{
receiverId: 'example2.near',
actions: [
/* actions */
],
},
],
})
Last updated on