近跨合约调用(允许一个账户将资金从托管释放到另一个账户)

2024-03-17

我正在尝试学习如何允许 1 个帐户(“捐赠匹配器”)将资金存入第二个帐户(本合同 https://github.com/ryancwalsh/donation-matching/blob/0a7bd3e39e79aec480367d0425d807c1915a2310/src/simple/assembly/index.ts#L87-L90,充当“托管”帐户),然后允许第三个帐户(常规“捐赠者”)触发该帐户发送到第四个帐户(“接收者”,例如慈善机构)。

我作为占位符编写的函数可能没有任何意义,因为我假设(按照当前编写的方式)它可能会从调用者/签名者而不是托管/自我/合约转移资金:

function transferFromEscrow(destinationAccount: AccountId, amount: u128): ContractPromiseBatch {
  // TODO: Fix this function!
  const toDestinationAccount = ContractPromiseBatch.create(destinationAccount);
  return toDestinationAccount.transfer(amount);
}

谢谢你的帮助!

This 官方 NEAR 仓库 https://github.com/near-examples/cross-contract-calls/tree/a589ab817835f837201f4afa48be5961d8ce5360#organization让我期待看到工作示例index.ts https://github.com/near-examples/cross-contract-calls/blob/a589ab817835f837201f4afa48be5961d8ce5360/contracts/01.using-single-calls/src/01-local/assembly/index.ts and 02.使用多个调用 https://github.com/near-examples/cross-contract-calls/tree/a589ab817835f837201f4afa48be5961d8ce5360/contracts/02.using-multiple-calls,但我没有看到任何。

I also posted this question to https://github.com/near-examples/cross-contract-calls/issues/13 https://github.com/near-examples/cross-contract-calls/issues/13


如上所述here https://stackoverflow.com/questions/62677188/how-can-i-move-near-token-from-one-account-to-other-using-contract/62677189,无法从其他帐户提取/转移代币,因此您应该以要求用户将一些代币存入您的合约的方式设计您的合约(通过类似存款的函数调用附加代币)。核心合约中有这种模式的很好的例子:

  • 锁定合约 https://github.com/near/core-contracts/tree/master/lockup按计划锁定资金
  • 质押池 https://github.com/near/core-contracts/tree/master/staking-pool锁定委托权益的代币
  • 多重签名合约 https://github.com/near/core-contracts/tree/master/multisig使用两次调用来启用 2FAadd_request具有未来调用的所有参数的函数和confirm接受前一个请求并执行它的函数
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

近跨合约调用(允许一个账户将资金从托管释放到另一个账户) 的相关文章

随机推荐