【问题标题】:How to require a true value in Clarity smart contract?如何要求 Clarity 智能合约的真实价值?
【发布时间】:2020-11-17 14:59:47
【问题描述】:

在我的智能合约中,我想检查一个布尔值是否为真,如果不是,智能合约应该中止或抛出类似的错误

(begin
   (require-true value)
   ...continue
)

我该怎么做?

【问题讨论】:

标签: blockchain smartcontracts clarity clarity-lang


【解决方案1】:

你可以在函数中使用unwrap-panic,例如

(define-private (require-true (value bool))
  (unwrap-panic (if value (some true) none))
)

【讨论】:

    猜你喜欢
    • 2017-08-19
    • 2022-10-25
    • 1970-01-01
    • 2017-04-06
    • 2022-08-02
    • 1970-01-01
    • 2022-01-05
    • 2023-01-25
    • 2022-12-06
    相关资源
    最近更新 更多