caver.kct.kip37
caver.kct.kip37 "可帮助您在 kaia 区块链上轻松处理以 JavaScript 对象形式实现 KIP-37 的智能合约。
caver.kct.kip37 "继承了caver.contract,以实现 KIP-37 代币合约。 caver.kct.kip37 "拥有与 "caver.contract "相同的属性,但还有其他方法来实现额外的功能。 本节仅介绍 "caver.kct.kip37 "新增的绑定方法。
为 caver-js 实现 KIP-37 的代码可在 Kaia Contracts Github Repo 上获取。 用于 caver-js 的 KIP-37 支持 Ownable 接口。 使用此功能,您可以在部署合约时指定合约所有者
有关 KIP-37 的更多信息,请参阅 Kaia 改进提案。
注意 caver.kct.kip37
从 caver-js v1.5.7 开始支持。
caver.kct.kip37.deploy
caver.kct.kip37.deploy(tokenInfo, deployer)
将 KIP-37 代币合约部署到 kaia 区块链上。 使用 caver.kct.kip37.deploy 部署的合约是一种遵循 KIP-37 标准的不可篡改令牌。
成功部署后,将使用新的 KIP17 实例解 决承诺问题。
参数
名称 | 类型 | 描述 |
---|---|---|
tokenInfo | object | 在 kaia 区块链上部署 KIP-37 代币合约所需的信息。 详见下表。 |
deployer | string \ | object |
tokenInfo 对象必须包含以下内容:
名称 | 类型 | 描述 |
---|---|---|
uri | string | 所有标记类型的 URI,依靠标记类型 ID 替换机制。 |
返回价值
PromiEvent`:一个承诺组合事件发射器,用一个新的 KIP17 实例来解决。 此外,还可能发生以下事件:
名称 | 类型 | 描述 |
---|---|---|
transactionHash | string | 在事务发送且事务哈希值可用后立即触发。 |
receipt | object | 当交易收据可用时触发。 如果您想了解收据对象内部的属性,请参阅 getTransactionReceipt。 来自 KIP17 实例的收据有一个通过 abi 解析的 "事件 "属性,而不是 "日志 "属性。 |
error | Error | 发送过程中发生错误时触发。 |
代币注册
-
要在区块资源管理器上注册代币,合约创建者必须填写一份提交申请表。 记下表格上所需的具体信息。
-
智能合约环境
-
编译器类型固态
-
编译器版本:v0.8.4+commit.c7e474f2
-
开源许可证类型:MIT
-
-
智能合约详情
-
优化: --optimize-run 200
-
源代码:KIP17 合约 Github 链接。
-
-
ABI 编码值:kip17JsonInterface at dev - kaiachain/caver-js - GitHub
示例
// using the promise> caver.kct.kip37.deploy({ uri: 'https://caver.example/{id}.json',}, '0x{address in hex}').then(console.log)KIP37 { ... _address: '0x7314B733723AA4a91879b15a6FEdd8962F413CB2', _jsonInterface: [ ... { anonymous: false, inputs: [{ indexed: false, name: 'value', type: 'string' }, { indexed: true, name: 'id', type: 'uint256' }], name: 'URI', type: 'event', signature: '0x6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b', } ] }// Send object as second parameter> caver.kct.kip37.deploy({ uri: 'https://caver.example/{id}.json', }, { from: '0x{address in hex}', feeDelegation: true, feePayer: '0x{address in hex}', }).then(console.log)// using event emitter and promise> caver.kct.kip37.deploy({ uri: 'https://caver.example/{id}.json',}, '0x{address in hex}').on('error', function(error) { ... }).on('transactionHash', function(transactionHash) { ... }).on('receipt', function(receipt) { console.log(receipt.contractAddress) // contains the new token contract address}).then(function(newKIP37Instance) { console.log(newKIP37Instance.options.address) // instance with the new token contract address})
caver.kct.kip37.detectInterface
caver.kct.kip37.detectInterface(contractAddress
返回代币合约实现的 接口信息。 此静态函数将使用 kip17.detectInterface。
参数
名称 | 类型 | 描述 |
---|---|---|
contractAddress | string | KIP-37 代币合约的地址 |
返回价值
Promise "会返回一个 "对象",其中包含每个KIP-37 接口是否已实现的布尔值结果。
示例
> caver.kct.kip37.detectInterface('0x{address in hex}').then(console.log){ IKIP37: true, IKIP37Metadata: true, IKIP37Mintable: true, IKIP37Burnable: true, IKIP37Pausable: true,}
caver.kct.kip37.create
caver.kct.kip37.create([tokenAddress
创建新的 KIP17 实例及其绑定的方法和事件。 该功能与 [new KIP17](#new-kip17)相同。
注意 caver.kct.kip37.create
从 caver-js v1.6.1 开始支持。
参数
请参见 [new KIP17](#new-kip17)。
返回价值
请参见 [new KIP17](#new-kip17)。
示例
// Create a KIP37 instance without a parameter> const kip37 = caver.kct.kip37.create()// Create a KIP37 instance with a token address> const kip37 = caver.kct.kip37.create('0x{address in hex}')
新 KIP17
new caver.kct.kip37([tokenAddress])