packagemainimport ("fmt""github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk")funcmain() { accountName :="Alice"//Zecrey NFT Marketplace SDK will automatically add the suffix ".zec" to the name seed :="0x6a1a320d14790f2d9aa9a37769f4833d583a3f7f974fd452a3990aeb0e7a6052"//l2 seedvar offerId int64=31//select a listed NFT AssetAmount = big.NewInt(1000000000000000000) //the amount used to purchase isSell :=false c, err := sdk.NewClient(accountName, seed) if err !=nil { panic(err) } result, err := c.AcceptOffer(offerId, isSell, AssetAmount)//false represents "buy" while true represents "sell"if err !=nil { panic(err) } data, _ := json.Marshal(result) fmt.Println(string(data))}
Example result
Information about the status change of the target order will be returned. Please refer to Offers for the status information.
The information returned is all about the target order except for "account_name".
{"offer":{"id":31,"account_name":"Alice",//User's account name"direction":"1","asset_id":241,"payment_asset_id":0, "payment_asset_amount":"1.000000000000000000",//This corresponds to the relative value of 10^18 of the AssetAmount(1000000)
"status":"2",//Status changed to 2 "signature":"{\"Type\":1,\"OfferId\":1,\"AccountIndex\":3,\"NftIndex\":247,\"AssetId\":0,\"AssetAmount\":1000000000000000000,\"ListedAt\":1667875678292,\"ExpiredAt\":1668350875000,\"TreasuryRate\":30,\"Sig\":\"kpaBoImpjmeI+PlOzkcCr7Tquf16qtriprOUUy3E1JUDjwcttXut8GEu6UV/H4dtJvnqKyD6FwK08hqv0vO67A==\"}",
"expired_at":1668350875000,"created_at":1667875678 }}