帐号包
软件开发包,可促进与链式Gnosis Pay账户的互动.
对于每个账户动作,这种SDK提供了充值交易有效载荷的功能. 生成的交易可以被转发,不需要额外的签名.
目录
账户创建
创建新的 1/1 保险箱 .
import { populateAccountCreation } from "@gnosispay/account-kit";
const createTx = populateAccountCreation({
owner: `0x<address>`,
});
await relayer.sendTransaction(createTx);
直接转让
签署账户中的 ERC20 令牌转出 。 用于新创建的 1/1 保险箱(设置前). 人口交易已准备就绪,不需要额外签字.
import { populateDirectTransfer } from "@gnosispay/account-kit";
const owner : Signer = {};
const nonce = `<number>`; // see Account Setup section, nonce comment
const transaction = await populateDirectTransfer(
{ safe: `0x<address>`, chainId: `<number>`, nonce: nonce },
{ token: `0x<address>`, to: `0x<address>`, amount: `<bigint>` },
// callback that wraps an eip-712 signature by owner
({ domain, primaryType, types, message }) => owner.signTypedData(...)
);
await relayer.sendTransaction(transaction);
账户设置
将1/1保险箱升级为Gnosis支付账户。 人口交易已准备就绪,不需要额外签字.
import {
createSetupConfig, populateAccountSetup,
} from "@gnosispay/account-kit";
const owner: Signer = {};
/*
* NOTE: on the nonce argument for "Account Setup":
* Unlike limit, spend or execute, this operation is performed on a basic safe.
* As a result, it depends on safe-core signatures and the safe-core nonce.
* Must query the on-chain safe nonce value and use it to sign the transaction.
*
* In contrast, limit/spend/execute actions run on Zodiac Modifier signatures,
* which use signer-proposed salts for replay protection and do not require
* on-chain querying of the nonce.
*/
const nonce = `<number>`;
const config: SetupConfig = createSetupConfig({
token: `0x<address>`, chainId: `<number>`
})
const transaction = await populateAccountSetup(
{
account: `0x<address>`,
owner: owner.address,
chainId: `<number>`,
nonce: nonce
},
config,
// callback that wraps an eip-712 signature !!owner signs!!
({ domain, primaryType, types, message }) => owner.signTypedData(...)
);
await relayer.sendTransaction(transaction);
执行
此函数生成一个有效载荷来启动“ 延迟模式” 队列中的交易执行 。 冷却期过后,交易可以执行. 人手交易已准备就绪,不需要再签字.
import {
populateExecuteEnqueue,
populateExecuteDispatch,
} from "@gnosispay/account-kit";
const owner : Signer = {};
const innerTransaction = {
to: `0x<address>`,
value: `<bigint>`,
data: `0x<bytes>`
};
const enqueueTx = await populateExecuteEnqueue(
{ account: `0x<address>`, chainId: `<number>` },
innerTransaction,
// callback that wraps an eip-712 signature !!owner signs!!
({ domain, primaryType, types, message }) => owner.signTypedData(...)
);
await relayer.sendTransaction(enqueueTx);
// ⏳ wait cooldown seconds ⏳
const dispatchTx = populateExecuteDispatch(
{ account },
innerTransaction
);
await relayer.sendTransaction(dispatchTx);
限制
此函数生成一个有效载荷, 启动“ 延迟模式” 队列中的允许变化 。 冷却期过后,可以实行津贴变更. 所有人对津贴配置保持单方面控制。 人手交易已准备就绪,不需要再签字.
import {
populateLimitEnqueue,
populateLimitDispatch,
} from "@gnosispay/account-kit";
const owner : Signer = {};
const allowanceConfig : AllowanceConfig = {
period: `<number>`, // duration, in seconds
refill: `<bigint>`, // amount added to balance, per period
};
const enqueueTx = await populateLimitEnqueue(
{ account: `0x<address>`, chainId: `<number>` },
allowanceConfig,
// callback that wraps an eip-712 signature !!owner signs!!
({ domain, primaryType, types, message }) => owner.signTypedData(...)
);
await relayer.sendTransaction(enqueueTx);
// ⏳ wait cooldown seconds ⏳
const dispatchTx = populateLimitDispatch(
{ account: `0x<address>` },
allowanceConfig
);
await relayer.sendTransaction(dispatchTx);
花费
此函数生成执行付款时要提交的耗用的有效载荷。 通过每个账户的"角色模式",支出者只要不超出设定的"津贴"限额,就可以单方面使用. 人口交易已准备就绪,不需要额外签字.
import { populateSpend } from "@gnosispay/account-kit";
const delegate: Signer = {}; // the spend delegate, configured in the Gnosis Pay Spender Safe
const transfer: Transfer = {
token: `0x<address>`,
to: `0x<address>`,
amount: `<bigint>`,
};
const spendTx = await populateSpend(
{ account: `0x<address>`, spender: `0x<address>`, chainId: `<number>` },
transfer,
// callback that wraps an eip-712 signature !!spender signs!!
({ domain, primaryType, types, message }) => spender.signTypedData(...)
);
await relayer.sendTransaction(spendTx);
账户查询
这个函数生成一个多调有效载荷,收集所有必要的数据来评价给定的Gnosis Pay账户是否符合完整性要求. 然后,它返回一个完整性状态代码以及应计津贴余额.
import { accountQuery } from "@gnosispay/account-kit";
const {
status,
allowance: { balance, refill, period, maxRefill, nextRefill },
} = await accountQuery(
{ account: `0x<address>`, cooldown: `<number>` },
// a function that receives a tx and performs eth_call, library agnostic
({ to, data }) => provider.send("eth_call", [{ to, data }])
);
贡献者
- 克里斯托万·霍诺拉托(签名)克丽斯多瓦特(中文(简体) )
许可证
这个项目根据Apache许可证2.0获得许可——见 自由主义 详细文件.