You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kadena域名注册智能合约REPL测试报错:with-read行未找到

Kadena Pact域名注册合约测试报错:with-read row not found

问题场景

开发了Kadena Pact域名注册智能合约,通过REPL文件name.repl测试name.pact中free.testingdomain模块的域名注册功能。项目结构为:pact目录下包含主合约name.pact、测试文件name.repl,以及存放coin依赖模块的root目录。执行(load "name.repl")时,反复触发以下错误:

pact> (load "name.repl")
"Loading name.repl..."
"Begin Tx 0: Load modules"
"Setting transaction data"
"Namespace defined: free"
"Loading root/fungible-v2.pact..."
"Loaded interface fungible-v2"
"Loading root/fungible-xchain-v1.pact..."
"Loaded interface fungible-xchain-v1"
"Loading root/coin-v5.pact..."
"Loaded module coin, hash b05fAfvjpnvnl_ssUgyTNkOIAN398ecTuTsUlW_RKyg"
"TableCreated"
"TableCreated"
"Loading name.pact..."
"Namespace set to free"
"Keyset defined"
Warning: using deprecated native overload for *: decimal/integer operator overload is deprecated
"Loaded module free.testingdomain, hash F-bf3MGSDKBq090p9Rig-f7mfAQO0Boh-YdjeFvSejk"
"Commit Tx 0: Load modules"
"Begin Tx 1: Create KDA accounts"
"Write succeeded"
"Write succeeded"
"Setting transaction data"
"Capability acquired"
"Write succeeded"
"Commit Tx 1: Create KDA accounts"
"Begin Tx 2: Try buying a domain name"
"Using free.testingdomain"
"Setting transaction signatures/caps"
root/coin-v5.pact:350:6: with-read: row not found: k:36990b871267ec4532551e505260806d7f39378cebb5ea2c998c80301c5a100f
 at root/coin-v5.pact:350:6: (with-read (deftable coin-table:(defschema coin-schema "The c... "k:36990b871267ec4532551e505260806d7f39378cebb5ea2... ({g:<ah> "guard"} [(coin.credit "k:36990b871267ec4...)
 at root/coin-v5.pact:348:4: (with-capability (coin.TRANSFER "alice" "k:36990b871267ec4532551e50... [(coin.debit "alice" 1.0) (native `with-read`  Spe...)
 at name.pact:224:6: (transfer "alice" "k:36990b871267ec4532551e505260806d7f39378cebb5ea2... 1.0)
 at name.pact:222:4: (with-capability (free.testingdomain.MAPPING) [(coin.transfer "alice" "k:36990b871267ec4532551e5...)
 at name.pact:221:4: (with-capability (free.testingdomain.NAME_UPSERT "elijahd.kda") [(native `with-capability`  Specifies and requests...)
 at name.pact:220:4: (with-capability (free.testingdomain.ACCOUNT_GUARD "alice") [(native `with-capability`  Specifies and requests...)
 at name.pact:219:4: (with-capability (free.testingdomain.NAME_AVAILABLE "elijahd.kda") [(native `with-capability`  Specifies and requests...)
 at name.repl:58:0: (register "alice" "k:2cf3e52a1e9e961257599a5155cc5ef3e836fc8f70b7edf... "elijahd.kda" 365)
pact>

错误原因

错误日志显示,执行coin.transfer时,尝试读取目标账户k:36990b871267ec4532551e505260806d7f39378cebb5ea2c998c80301c5a100f的记录,但该账户未在coin表中创建,导致with-read操作失败。

解决方案

  • 初始化费用接收账户:在name.repl的Tx1(Create KDA accounts)阶段,添加创建目标账户的代码。示例:
    (coin.create-account "k:36990b871267ec4532551e505260806d7f39378cebb5ea2c998c80301c5a100f" (read-keyset "fee-account-guard"))
    
    同时需要提前定义对应的keyset,确保账户有合法的guard。
  • 校验合约中的转账目标地址:检查name.pact中transfer调用的目标地址是否正确,确认地址字符串没有拼写错误或生成错误。
  • 确认权限能力配置:确保调用register函数时,已正确获取coin.TRANSFER能力,或者合约内部已正确处理转账所需的权限校验。

内容的提问来源于stack exchange,提问作者advanztek

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 02:50:14