Smart Contract - Direct Sale
This guide covers the specific actions needed to use the API to generate Smart Contracts for a Direct NFT Sale.
Note - this guide uses the Testnet, the Python Requests Library and the NMKR wallet playground.
The methods are not currently live for the production system.

Setup the Sale

Preamble

The objective of this flow is to be able to publish a Smart Contract that will hold an NFT, waiting for a specific amount of ADA to be sent to it. At which point it will then accept the ADA, send the NFT to the buyer and then distribute the funds received amongst the original owner, the marketplace and any other royalties.
This guide also serves to show the minimal implementation of this flow, full details of each API Method Call can be found in the Swagger API Documentation.
You will need your API Key to perform any actions related to the API.
These Smart Contract Related methods all work in phases, keep this model in mind as you progress through the guide:
  1. 1.
    Initialise, Setup
  2. 2.
    Sign
  3. 3.
    Submit

CreatePaymentTransaction

This is a HTTP POST API Call.
The first step in the process is to create the payment transaction, this serves to initialise all of the variables. This method is special, as it can be used to set up various flows depending on the JSON payload that you decide to apply.
Key Inputs:
  • baseApiCall: 'https://api-testnet.nmkr.io/v2/CreatePaymentTransaction/'
  • projectUid
  • paymentTransactionType: smartcontract_directsale
  • transactionParameters
    • tokencount
    • policyId
    • tokenname
  • directSaleParameters
    • priceInLovelace
  • customerIpAddress - in a real implementation, you will need to get the IP of the user
Key Outputs:
  • paymentTransactionUid
  • paymentTransactionType
  • state
  • transactionParameters
  • directSaleResults
  • auctionResults (should be null)
Example Code:
def TESTNETcreatePaymentTX():
baseApiCall = 'https://api-testnet.nmkr.io/v2/CreatePaymentTransaction/'
JSONpayload = {
"projectUid": "aaaaaaa-bbbb-cccc-dddd-eeeeeeeeee",
"paymentTransactionType": "smartcontract_directsale",
"transactionParameters": [
{
"tokencount": 1,
"policyId": "761a9ea695f98424a278bc2b244d8bf83aec12774c94f39b7679576e",
"tokenname": "Testnet01"
}
],
"directSaleParameters": {
"priceInLovelace": 50000000
},
"customerIpAddress": "127.0.0.1"
}
REQ = requests.post(baseApiCall,headers={"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxx"},json=JSONpayload)
print(REQ)
print(REQ.content)
Your Project UID = aaaaaaa-bbbb-cccc-dddd-eeeeeeeeee Your API Key = xxxxxxxxxxxxxxxxxxxxxxx
Note - look carefully at line 21, where the API Key is placed inside the HTTP headers.
In response to running this code, you should receive a JSON Payload as follows, make sure that the outputs match your inputs:
{
"paymentTransactionUid":"T7a103932c587427d85d3e654a90bb534",
"paymentTransactionType":"smartcontract_directsale",
"customProperties":{
},
"state":"prepared",
"transactionParameters":[
{
"tokencount":1,
"policyId":"761a9ea695f98424a278bc2b244d8bf83aec12774c94f39b7679576e",
"tokenname":"546573746E65743031"
}
],
"paymentTransactionCreated":"2022-03-27T11:14:21.4538055+00:00",
"paymentgatewayResults":null,
"paymentTransactionSubStateResult":{
"paymentTransactionSubstate":"waitingforlocknft",
"lastTxHash":null
},
"auctionResults":null,
"directSaleResults":{
"sellingPrice":50000000,
"marketplaceAmount":1000000,
"sellerAmount":51000000,
"royaltyAmount":0,
"additionalPayoutAmount":null,
"lockedInAmount":2000000
},
"cbor":null,
"signedCbor":null,
"expires":null,
"signGuid":null,
"fee":null
}
Note - you will need the paymentTransactionUid (line 2) for the next part.

LockNft

This is a HTTP POST API Call.
Now that we have the base transaction prepared, we need to prep and lock the NFT(s) we wish to place into the smart contract.
You will also need to be familiar with the concept of Collateral.
Key Inputs:
  • baseApiCall: 'https://api-testnet.nmkr.io/v2/ProceedPaymentTransaction/'+ paymentTransactionUid +'/LockNft'
  • paymentTransactionUid: from the result of CreatePaymentTransaction
  • addresses: from NMKR wallet playground
  • collateralTxIn: This is the transaction ID of when the Wallet CURRENTLY Holding the NFT(s) first committed its collateral, you can find this in the NMKR wallet playground.
  • changeAddress : from NMKR wallet playground
Note - many of these inputs can be gathered directly from the NMKR wallet playground
Key Outputs:
  • Cbor
  • signedCbor
  • signGuid
First of all, connect to your Nami Wallet.
Connect to your wallet
Once connected, note the addresses and other attributes that are displayed. You will need them for this part.
The PKH, Address and CollateralTX from your connected wallet.
Example Code:
def TESTNETLockNFT(trxUIDin):
baseApiCall = 'https://api-testnet.nmkr.io/v2/ProceedPaymentTransaction/'+ trxUIDin +'/LockNft'
JSONpayload = {
"seller": {
"pkh": "YOURpkhHERE",
"addresses": [
"yourAddressHERE"
],
"collateralTxIn": "yourCollateralTXInHERE",
"changeAddress": "yourAddressHERE"
}
}
REQ = requests.post(baseApiCall, headers={"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxx"},json=JSONpayload)
print(REQ.content)
trxUIDin = paymentTransactionUid from the result of CreatePaymentTransaction Your API Key = xxxxxxxxxxxxxxxxxxxxxxx
Note - look carefully at line 2, where the trxUIDin is placed inside the API Call. Look carefully at line 14, where the API Key is placed inside the HTTP headers.
In response to running this code, you should receive a JSON Payload containing lots of information about the transaction you are preparing, make sure that the outputs match your inputs and then look for the following variables:
.........
,
"cbor": "86a500828258201b0d3bb3a900d65ed8f8da4e448b5e203999657e221
4ffda573308171dfdc42e018258201bd8bddc5809389cc96aee908e40c814bda13cb837e6580c222
dbed228295a09020d8001838258390000315c188976ad7fb4ccb232ffa921362a873326b695115b5
1a079af2693dbb0dbb89533d............",
"signedCbor": "84a500828258201b0d3bb3a900d65ed8f8da4e448b5e203999657e2214ffda
573308171dfdc42e018258201bd8bddc5809389cc96aee908e40c814bda13cb837e6580c222dbed2
28295a09020d800183825839000031.....",
"expires": null,
"signGuid": "L009477e6223b44c........",
"fee": 179273
}
Note - you will need the signGuid and signedCbor for the next part.

Sign the Transaction

This is where you will need to use the NMKR wallet playground to simulate signing transactions. To do this, you will need to have a Nami Wallet as it is currently the only wallet that we support for testing this process.
You might have noticed by now that, so far we have not signed or confirmed anything as the actual owner of the NFT which means we cant actually submit the transaction yet. If we could do that, it would be very worrying!
Note - make sure you are on the TESTNET to avoid sending your real ADA or NFT's!
First of all, yake the signedCbor value from the previous step and drop this into the 'Cbor' field on the form. Yes, this is definitely the SIGNED Cbor.
Paste the Signed CBOR here
Press 'Sign with Smart TX'.
Signing the transaction with Smart Contracts
You will then be prompted for the password to your Nami Wallet, enter this and the site will then generate the final Signed TX CBOR (this is what we will need for the submission of the transaction).
Signed TX CBOR
Note - this is an even larger amount of characters, make sure you copy all of it (there will be a scroll bar!)

SubmitTransaction

This part will only work if you have completed all of the prior steps and you will specifically need the paymentTransactionUid from the result of CreatePaymentTransaction, the signGuid from the LockNft method and the Signed TX CBOR from the signing.
Inputs:
  • paymentTransactionUid
  • signGuid
  • Signed TX CBOR
Outputs:
  • The transaction is submitted to the blockchain
  • Various attributes and information related to the transaction.
Example Code:
def TESTNETSubmitTx(trxUIDin, signedTXCborin, signguidin):
baseApiCall = 'https://api-testnet.nmkr.io/v2/ProceedPaymentTransaction/'+ trxUIDin +'/SubmitTransaction'
JSONpayload = {
"signedCbor": signedTXCborin,
"signGuid": signguidin
}
REQ = requests.post(baseApiCall, headers={"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxx"},json=JSONpayload)
print(REQ.content)
Your API Key = xxxxxxxxxxxxxxxxxxxxxxx
Running this method will result in another 200 OK response, with a return payload that contains various information about the transaction.
The key element you need to look for is that the state be set to active (see line 8):
{
"paymentTransactionUid":"T79cb97a8001841fd845d3dcb23e6b167",
"projectUid":"c45c48d3-9235-4235-a218-a490df4fbd22",
"paymentTransactionType":"smartcontract_directsale",
"customProperties":{
},
"state":"active",
"transactionParameters":[
{
"tokencount":1,
"policyId":"761a9ea695f98424a278bc2b244d8bf83aec12774c94f39b7679576e",
"tokenname":"546573746E65743031"
}
],
"paymentTransactionCreated":"2022-03-31T19:57:33",
"paymentgatewayResults":null,
"paymentTransactionSubStateResult":{
"paymentTransactionSubstate":"waitingforsale",
"lastTxHash":"afafb9b9b0057b0927dd1b5822efcdb877c58305cb1883bf11e96da27ce2d28f"
},
"auctionResults":null,
"directSaleResults":{
"sellingPrice":50000000,
"marketplaceAmount":1000000,
"sellerAmount":51000000,
"royaltyAmount":0,
"additionalPayoutAmount":null,
"lockedInAmount":2000000
},
"cbor":null,
"signedCbor":null,
"expires":null,
"signGuid":null,
"fee":null
}
Note - look out for line 19, it should now say 'waitingforsale'
Awesome! You now have place a smart contract, on the Cardano Blockchain. This NFT is now free for anyone to purchase for the specified price.

Buy the NFT

Now that we have set up a sale, let's see what its like to make the purchase!
The important thing to consider here, is how the API requires you to pass the paymentTransactionUid for the related Smart Contract. Assuming your are following this guide chronologically, this will be the same one we have been using all along.
The paymentTransactionUid is first created in the original CreatePaymentTransaction and is used by the API (along with other parameters) to identify the Smart Contract.
The first method we need, is BuyDirectsale, which works in a similar way to the LockNft method we have already covered. This prepares the transaction, ready for you to sign it with your wallet and then finally submit with the API.
Note - this method will only work if you are interacting with a Direct Sale Smart Contract, as will have been specified in the original CreatePaymentTransaction:
"paymentTransactionType": "smartcontract_directsale",

BuyDirectsale

Inputs:
  • paymentTransactionUid: for the target Smart Contract
  • baseApiCall: 'https://api-testnet.nmkr.io/v2/ProceedPaymentTransaction/'+ paymentTransactionUid +'/BuyDirectsale'
  • addresses: from NMKR wallet playground
  • collateralTxIn: This is the transaction ID of when the Wallet CURRENTLY Holding the NFT(s) first committed its collateral, you can find this in the NMKR wallet playground.
  • changeAddress : from NMKR wallet playground
  • buyerOffer: this needs to match the price of the NFT exactly, in lovelace
Key Outputs:
  • Cbor
  • signedCbor
  • signGuid
Example Code:
def TESTNETbuydirectsale(trxUIDin):
baseApiCall = 'https://api-testnet.nmkr.io/v2/ProceedPaymentTransaction/'+ trxUIDin +'/BuyDirectsale'
JSONpayload = {
"buyer": {
"pkh": "yourPKHhere",
"addresses": [
"yourAddrHere"
],
"collateralTxIn": "yourCollateralHere",
"changeAddress": "yourAddrHere"
},
"buyerOffer": 50000000
}
REQ = requests.post(baseApiCall, headers={"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxx"},json=JSONpayload)
print(REQ.content)
Your API Key = xxxxxxxxxxxxxxxxxxxxxxx
You will then receive the following response:
{
"paymentTransactionUid":"T79cb97a8001841fd845d3dcb23e6b167",
"projectUid":"c45c48d3-9235-4235-a218-a490df4fbd22",
"paymentTransactionType":"smartcontract_directsale",
"customProperties":{
},
"state":"active",
"transactionParameters":[
{
"tokencount":1,
"policyId":"761a9ea695f98424a278bc2b244d8bf83aec12774c94f39b7679576e",
"tokenname":"546573746E65743031"
}
],
"paymentTransactionCreated":"2022-03-31T19:57:33",
"paymentgatewayResults":null,
"paymentTransactionSubStateResult":{
"paymentTransactionSubstate":"readytosignbybuyer",
"lastTxHash":null
},
"auctionResults":null,
"directSaleResults":{
"sellingPrice":50000000,
"marketplaceAmount":1000000,
"sellerAmount":51000000,
"royaltyAmount":0,
"additionalPayoutAmount":null,
"lockedInAmount":2000000
},
"cbor":"86a600838258205c327e5exxxx13166xxxxxx04825820afafb9b9b0057b0927dd1b5822efcdb877c58305cb1883bf11e96da27ce2d28f010d818258205c327e5e81fe04a38aa5929c713166dfe949124cfa7f16327e4805260605547e0001858258390000315c188976ad7fb4ccb232ffa921362a873326b695115b51a079af2693dbb0dbb89533df4b205ba460fdfea54d2aa0430dc1aa420d28bf1a00226a2e8258390000315c188976ad7fb4ccb232ffa921362a873326b695115b51a079af2693dbb0dbb89533df4b205ba460fdfea54d2aa0430dc1aa420d28bf1a030a32c082581d6011a7d2d41bbf2929f421b07d1df8e53382c970b760a96506720fd8241a000f42408258390000315c188976ad7fb4ccb232ffa921362a873326b695115b51a079af2693dbb0dbb89533df4b205ba460fdfea54d2aa0430dc1aa420d28bf821a001e8480a1581c761a9ea695f98424a278bc2b244d8bf83aec12774c94f39b7679576ea149546573746e65743031018258390000315c188976ad7fb4ccb232ffa921362a873326b695115b51a079af2693dbb0dbb89533df4b205ba460fdfea54d2aa0430dc1aa420d28bf821a2b879478a1581c761a9ea695f98424a278bc2b244d8bf83aec12774c94f39b7679576ea14a426f6f6372657741393901021a000b5c920e81581c00315c188976ad7fb4ccb232ffa921362a873326b695115b51a079af0b5820252e2428acbab9becccc6e206fbd222386fed7bf98dc4894ef6ccfa52ea989569f8201590f35590f32010000332332233322233223322323232323233322233223233322232333222323333333322222222323332223233332222323233223233322232332233223232333332222233223322332233223322332222323223232232325335303033300a3333573466e1cd55cea8042400046608e6eb8d5d0a80419a80e8259aba135744a010464c6a60a066ae7013414413012ccccd5cd19b875004480088c128cd407412cd5d09aab9e500623333573466e1d40152000204a232635305133573809c0a409a0980966666ae68cdc39aab9d5002480008cc034c8c8c8c8c8c8c8c8c8c8c8cccd5cd19b8735573aa01490001199999999980d99a814919191999ab9a3370e6aae7540092000233021303735742a004605c6ae84d5d1280111931a983019ab9c05d06105c05b135573ca00226ea8004d5d0a80519a8148151aba150093335505b75ca0b46ae854020ccd5416dd7282d1aba1500733502904035742a00c66a05266aa0a2092eb4d5d0a8029919191999ab9a3370e6aae754009200023350233232323333573466e1cd55cea80124000466a05666a07eeb4d5d0a80118221aba135744a004464c6a60c866ae7018419418017c4d55cf280089baa00135742a0046464646666ae68cdc39aab9d5002480008cd40a4cd40fdd69aba150023044357426ae8940088c98d4c190cd5ce03083283002f89aab9e5001137540026ae84d5d1280111931a983019ab9c05d06105c05b135573ca00226ea8004d5d0a80219a814bae35742a00666a05266aa0a2eb88004d5d0a801181b1aba135744a004464c6a60b866ae7016417416015c4d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d55cf280089baa00135742a0046464646666ae68cdc3a800a400c4604060706ae84d55cf280191999ab9a3370ea00490021180f98211aba135573ca00846666ae68cdc3a801a40044603e605a6ae84d55cf280291999ab9a3370ea0089000118111bae357426aae7940188c98d4c15ccd5ce02a02c02982902882802789aab9d5001137540026ae84d5d1280111931a982819ab9c04d05104c04b1050132635304f3357389201035054350005004b135573ca00226ea80044d55cea80089baa001135573ca00226ea80048848cc00400c0088004888888888848cccccccccc00402c02802402001c01801401000c00880048848cc00400c008800448848cc00400c0084800448848cc00400c0084800448848cc00400c00848004848888c010014848888c00c014848888c008014848888c004014800448c88c008dd6000990009aa81e911999aab9f0012503d233503c30043574200460066ae880080dc8c8c8c8cccd5cd19b8735573aa006900011998039919191999ab9a3370e6aae754009200023300d302c35742a00466a01c0506ae84d5d1280111931a981d99ab9c03803c037036135573ca00226ea8004d5d0a801999aa81b3ae503535742a00466a014eb8d5d09aba25002232635303733573806807006606426ae8940044d55cf280089baa001222123330010040030022001221233001003002200112232323333573466e1d400520002350083005357426aae79400c8cccd5cd19b87500248008940208c98d4c0cccd5ce01801a01781701689aab9d500113754002242446004006224400224002464646666ae68cdc39aab9d5002480008cc018c01cd5d0a8011bad357426ae8940088c98d4c0b4cd5ce01501701481409aab9e50011375400244246600200600440024646666ae68cdc39aab9d5001480008dd71aba135573ca004464c6a605266ae700980a80940904dd500089119191999ab9a3370ea00290021280391999ab9a3370ea004900111a80518031aba135573ca00846666ae68cdc3a801a40004a014464c6a605866ae700a40b40a009c0980944d55cea80089baa00112122230030041122200211222001120012323333573466e1d40052002200623333573466e1d400920002006232635302433573804204a04003e03c26aae74dd50008910010910009000919191919191999ab9a3370ea0029006100591999ab9a3370ea0049005100691999ab9a3370ea00690041198059bae35742a00a6eb4d5d09aba2500523333573466e1d4011200623300d375c6ae85401cdd71aba135744a00e46666ae68cdc3a802a400846602460286ae854024dd71aba135744a01246666ae68cdc3a8032400446028602a6ae84d55cf280591999ab9a3370ea00e900011809980b1aba135573ca018464c6a605266ae700980a809409008c08808408007c0784d55cea80209aab9e5003135573ca00426aae7940044dd500090911111118038041109111111198030048041091111111802804091111110020911111100191091111111980100480411091111111980080480410009191919191999ab9a3370ea002900111998041bad35742a0086eb4d5d0a8019bad357426ae89400c8cccd5cd19b875002480008c028c02cd5d09aab9e5006232635301a33573802e03602c02a02826aae75400c4d5d1280089aab9e5001137540024244600400644424466600200a0080064002464646666ae68cdc3a800a40044600c6eb8d5d09aab9e500323333573466e1d4009200023008375c6ae84d55cf280211931a980a19ab9c01101501000f00e135573aa00226ea80048488c00800c8488c00400c800444888c8c8cccd5cd19b8735573aa0049000119aa80c98031aba150023005357426ae8940088c98d4c044cd5ce00700900680609aab9e5001137540024424660020060044002424460040062440024002464646666ae68cdc39aab9d5002480008cc030dd71aba150023335500875ca00e6ae84d5d1280111931a980499ab9c00600a005004135573ca00226ea800526490103505431001335500175ceb44488c88c008dd5800990009aa80611191999aab9f0022500d233500c335500f300635573aa004600a6aae794008c010d5d100180389aba100112001200122123300100300220011122002122122330010040031200111221233001003002112001112323001001223300330020020013233322232332233322233322233223322333222332233223232323322333222332233223232323232323333222232332232323232323322332233223232323232222325335302600321330213300a491144f7574707574732061726520696e76616c69642100335502d2335502e33223355002350255023001301f1200123535503800122335017332233355301e12001500c503b3530150022222222222333553028120012235304300222235304d00322335305400225335305b333573466e3c04c0041741704cd413001401c401c801d41140254018008004004cd540b4ccd554044c07848004cc8888cd54c084480048d4d540ec00488cd540f8008ccd4d54080004800488cc0200080048004ccd55406401000800407c88ccc02402800800540d4cd540b4d54c04848004cd5540b0c88d4d540e000488cc01000800488cd40d8cd540e400800540dc8d4c0ac00488cd540e8008004cc88ccd54c0684800540d8004008d4c02c01488004004cc02924118496e7075742076616c756520697320696e636f727265637400335013335502d3355502c2353032001222002009533535033335502d3355502c323355301912001225335304630030021335037002001100150363355502c2353039001223353040002204820493355502c23530320012220030092353010001222222222200a50021302e4988854cd4d40d40044008884c0c9263333555011301e12001223332001500835302c0022200100150350011335502c3009491194e6f74207369676e6564206279204e46542073656c6c65722100332235301000222222222225335350453335530291200133502f22533535047002210031001504625335304f333573466e3c0300041441404d41200045411c00c84144413d4004d4c028010880084d4c02c004880084c004008888cd54c064480048d4d540cc00488cd540d8008cd54c070480048d4d540d800488cd540e4008ccd4d5406c0048cc0292000001223300b00200123300a00148000004cc04000800488cdc000100091a98138009100091299a981d800881e899ab9c00203c22123300100300220012212330010030022001222222222212333333333300100b00a0090080070060050040030022001111222233335500433501722230033002001200100300100232001355034221122533535025001150272213350283004002335530061200100400112233355300d1200135011500f235355026001223335530101200135014501223535502900122333535500e0012330384800000488cc0e40080048cc0e0005200000133003002001223355300b12001235355025001223355028002333535500a00123355300f1200123535502900122335502c0023550110010012233355500801200200123355300f1200123535502900122335502c00235500f00100133355500300d0020011112223335530061200150223355300b1200123535502500122335502800235500d001333553006120012235355026002225335303533355301012001323350172233353500b00322002002001353500900122001335009225335303700210391001036235355029001223300a0020050061003133502600400350230013355300b120012353550250012232335502900330010053200135503722533535026001135500d0032213535502b002225335303a3300c00200813355012007001130060030021221233001003002120013200135502e221122253353502000110022213300500233355300712001005004001112122230030041122122233002005004112122230010041120013200135502922112253353501a0011501c22133501d3004002335530061200100400132001355028221122253353501a0011353500a0032200122133353500c0052200230040023335530071200100500400122333573466e3c0080040a009c4cd4018004094894cd4c0900084004409448cd400c88ccd4d401800c88008008004d4d40100048800448848cc00400c0084800448848cc00400c008480048488c00800c48800480048848cc00400c0088004444888c00cc0080044488c0080048c98d4c04ccd5ce2492165787065637465642065786163746c79206f6e652073637269707420696e707574000144988848cc00400c008800488848ccc00401000c00880044488008488488cc00401000c48004448848cc00400c0084480048848cc00400c008800448488c00800c4488004480048488c00800c8488c00400c800448004800488ccd5cd19b880020010040051220021220012001112323001001223300330020020011ff81d8799f581c00315c188976ad7fb4ccb232ffa921362a873326b695115b51a079af9fd8799f581c00315c188976ad7fb4ccb232ffa921362a873326b695115b51a079afa140a1401a030a32c0ffd8799f581c11a7d2d41bbf2929f421b07d1df8e53382c970b760a96506720fd824a140a1401a000f4240ffffff81840002d87a9f9fd8799f581c00315c188976ad7fb4ccb232ffa921362a873326b695115b51a079afa1581c761a9ea695f98424a278bc2b244d8bf83aec12774c94f39b7679576ea149546573746e6574303101ffffff821a00437d9e1a5901967ef5f6",
"signedCbor":"166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d166xxxxxx04825820afafb9b9b0057b0927d",
"expires":null,
"signGuid":"166xxxxxx04825820afafb9b9b0057b0927d",
"fee":744594
}
Note - line 19 should say "paymentTransactionSubstate":"readytosignbybuyer"
Also note that the signedCbor is a massive string of hundreds of characters.
You will need the signedCbor (line 32) and signGuid (line 34) for the next steps.

Sign the Transaction

Well done, you have now prepared the transaction, follow the same steps as you did before to sign it, at a high level, you need to:
  1. 1.
    Copy the signedCbor from the BuyDirectSale method
  2. 2.
    Paste this into the 'Enter CBOR here then press sign' box
  3. 3.
    Press Sign TX or Sign TX with SC
  4. 4.
    Enter wallet password
  5. 5.
    Copy the Signed TX CBOR
  6. 6.
    Note the Singed TX CBOR for the next step

SubmitTransaction

Similarly to the Setting up the sale, we now need to submit the BuyDirectSale transaction we just made to the blockchain.
This works exactly the same as it did when we setup the sale.
In short, run the SubmitTransaction API Call, using:
  • paymentTransactionUid
  • signGuid (from line 34 of the BuyDirectSale method)
  • Signed TX CBOR (from point 6 above)

Summary

Well done! You have now completed the full cycle of setting up a Smart Contract Direct Sale and then making the purchase using that Smart Contract as the buyer. As I hope is clear, this functionality has the power to become the backbone of far more complex systems ranging from a custom marketplace, to specific project implementations - enjoy!
Copy link
On this page
Setup the Sale
Preamble
CreatePaymentTransaction
LockNft
Sign the Transaction
SubmitTransaction
Buy the NFT
BuyDirectsale
Sign the Transaction
SubmitTransaction
Summary