文档中的示例:https://docs.near.org/tutorials/examples/escrow
下面是运行自述文件中示例的完整步骤。md文件:https://github.com/near-examples/escrow-js
- 登录您的NEAR帐户
near login
- 创建用于部署合同的子帐户
near create-account --accountId <your-escrow-testnet-account-id> --masterAccount <your-testnet-account-id> --initialBalance <your-escrow-testnet-account-balance>
near create-account --accountId <your-assets-testnet-account-id> --masterAccount <your-testnet-account-id> --initialBalance <your-assets-testnet-account-balance>
我替换:
<your-testnet-account-id> : gettherefast.testnet
<your-escrow-testnet-account-id> : escrow.gettherefast.testnet
<your-assets-testnet-account-id> : assets.gettherefast.testnet
- 部署合同
near deploy --wasmFile build/escrow.wasm --accountId <your-escrow-testnet-account-id>
near deploy --wasmFile build/assets.wasm --accountId <your-assets-testnet-account-id>
- 初始化资产合同
near call <your-assets-testnet-account-id> init '{"owner_id": "<your-asset-owner-account-id>", "total_supply": "1000", "escrow_contract_id": "<your-escrow-testnet-account-id>", "asset_price": "100000000000000000000000"}' --accountId <your-assets-testnet-account-id>
有一个我不知道的新帐户:
<your-asset-owner-account-id>
- 在第三方托管上执行购买
near call <your-escrow-testnet-account-id> purchase_in_escrow '{"seller_account_id": "<your-asset-owner-account-id>", "asset_contract_id ": "<your-assets-testnet-account-id>"}' --accountId <your-buyer-account-id> --amount 0.11 --gas=300000000000000
和另一个
<your-buyer-account-id>
- 检查买方账户余额
near view <your-assets-testnet-account-id> get_account_assets '{"account_id": "<your-buyer-account-id>"}'
和另一个
near state <seller-account-id>
- 批准购买
near call <your-escrow-testnet-account-id> approve_purchase '{}' --accountId <your-buyer-account-id>
问题:用什么来代替它们:
<your-asset-owner-account-id>
<your-buyer-account-id>
<seller-account-id>
我对此没有想法。我有3个帐户,但我需要6个。
README可以更明确一点。我已经在存储库中更新了它,并将在短时间内更新文档。
至于如何处理这些帐户:
您实际上只需要另外两个帐户,即:
<your-asset-owner-account-id>
,包含所有所需资产或待售资产<your-buyer-account-id>
,这是一个试图以$NEAR的价格从资产持有人处购买资产的账户。
我建议您为每一个创建子帐户。我会把它们叫做asset-seller.gettherefast.testnet
和asset-buyer.gettherefast.testnet
。
对于<seller-account-id>
,在这个README示例中等于<your-asset-owner-account-id>
。所以我把这个替换为<your-asset-owner-account-id>
。