我需要有人来帮助我创建简单的智能资产。我只希望您不能在任何货币对下交易,并且只能将其发送到2个特定的Waves地址。有人可以帮我吗?
答案 0 :(得分:1)
您可以使用Data transaction中的Waves Console将地址列表添加到发件人帐户中(这里我在白名单中添加了两个地址),然后将交易广播到网络:
const DataTx =
data(
{
data: [
{key: "3Mt2yEuqDZVSfN7jqzvtkresLRah329k2ya", value: 12},
{key: "3N17vWKRThx5eKkPLC18UjyUuFr4X3sSKCD", value: 10}],
fee: 1500000
}
)
broadcast(DataTx)
对于智能合约,您可以使用pattern matching mechanism来允许转移交易,只需检查是否在发件人白名单帐户中定义了收件人地址,否则将不允许转移交易:
let whiteListAccount = tx.sender //In this line, we just defined the sender (in our case Bob).
match tx
{
case tx : TransferTransaction => let recipient = toBase58String(addressFromRecipient(tx.recipient).bytes)
isDefined(getInteger(whiteListAccount, recipient))
case _ => true
}
之后,您将需要编译智能合约并通过Waves Console设置脚本,如下所示:
const Tx = setScript
(
{
Script: compile(contract()),
senderPublicKey:publicKey(),
Fee:1400000
}
)
broadcast(Tx)