sequenceDiagram
actor Alice
participant Module
actor Bob
Alice ->> Module: transfer 10token (price 20stake)
Note over Module: have 10token
Bob ->>+ Module: request receive
Module ->> Alice: transfer 20stake from Bob<br/> (tx is signed by bob)
Module ->>- Bob: transfer 10token
Note over Alice: have 20stake
Note over Bob: have 10token
Swap or Sell Non Fungible Token
sequenceDiagram
actor Alice
participant Module
actor Bob
Alice ->> Module: transfer NFT (price 20stake)
Note over Module: have NFT
Bob ->>+ Module: request receive
Module ->> Alice: transfer 20stake from Bob<br/> (tx is signed by bob)
Module ->>- Bob: transfer NFT
Note over Alice: have 20stake
Note over Bob: have NFT
Commands
simd is your blockchain cli built by ignite chain build.
Any number of type uint64. It must be unique for --from user. If swap is completed by cancel or receive, it can be reused.. If swap is completed by cancel or receive, it can be reused
1
[receiver]
The recipient's address
cosmos1p496u9my9uv6s3klsxuhud5y7jxwmd4lal8ym4
[amount]
The amout of token to transfer
10tokenA
[amountToReceive]
The amount of tokens required for the recipient to receive
20tokenB
$ simd query swap show [sender] [id]
# ex) simd query swap show cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m 1 # Here is the result# swap:# creator: cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m# id: "1"# receiver: cosmos1p496u9my9uv6s3klsxuhud5y7jxwmd4lal8ym4# amount: 10tokenA# amountToReceive: 20tokenB
Any number of type uint64. It must be unique for --from user. If swap is completed by cancel or receive, it can be reused.. If swap is completed by cancel or receive, it can be reused
1
[receiver]
The recipient's address
cosmos1p496u9my9uv6s3klsxuhud5y7jxwmd4lal8ym4
[classId]
The NFT's classId
class1
[nftId]
The NFT's nftId
class1
[amountToReceive]
The amount of tokens required for the recipient to receive
It must match the address specified in [creator] in saved sale
alice
Sell Fungible Token
$ simd tx sale sell [id] [amount] [amountToReceive] --from keyname
# ex) simd tx sale sell 1 10coin 1stake --from alice
proeprty
description
ex
[id]
Any number of type uint64. It must be unique for the signer. If swap is completed by cancel or receive, it can be reused.. If swap is completed by cancel or receive, it can be reused
1
[amount]
The amount of token to transfer
10tokenA
[amountToReceive]
The amount of tokens required for the recipient to receive
20tokenB
$ simd query sale show [seller] [id]
# ex) simd query sale show cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m 1 # Here is the result# sell:# creator: cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m# id: "1"# amount: 10tokenA# amountToReceive: 20tokenB
$ simd tx sale buy [seller] [id] --from keyname
# ex) simd tx sale buy cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m 1 --from bob
proeprty
description
ex
[id]
The id specified when selling
1
[seller]
The address of the seller(sale creator)
cosmos1p496u9my9uv6s3klsxuhud5y7jxwmd4lal8ym4
--from
The buyer
bob
$ simd tx sale cancel [id] --from keyname
# ex) simd tx sale cancel 1 --from alice
proeprty
description
ex
[id]
The id specified when selling
1
--from
It must match the address specified in [creator] in saved sale
alice
Sell Non Fungible Token
$ simd tx sale sell-nft [id] [classId] [nftId] [amountToReceive] --from keyname
# ex) simd tx sale sell-nft 1 class1 nft1 --from alice
proeprty
description
ex
[id]
Any number of type uint64. It must be unique for --from user. If swap is completed by cancel or receive, it can be reused.. If swap is completed by cancel or buy, it can be reused
1
[classId]
The NFT's classId
class1
[nftId]
The NFT's nftId
class1
[amountToReceive]
The amount of tokens required for the recipient to receive
20tokenB
--from
It must be the owner of the NFT
alice
$ simd query sale show-nft [sender] [id]
# ex) simd query sale show-nft cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m 1 # Here is the result# sale:# amountToReceive: 3token# classId: class1# creator: cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m# id: "1"# nftId: nft1
$ simd tx sale buy-nft [seller] [id] --from keyname
# ex) simd tx sale buy-nft cosmos1s7p7h4k3v9qcqs7ku2tpq0cajydertggeg8z4m 1 --from bob