Skip to main content

Purchase process

The payment process requires a escrow contract to be originated.

Connect to wallet

Connect to the wallet by clicking the "Connect to wallet" button:

Docusaurus with Keytar

Then select the user account. If you don't have a dedicated user account, go to the Presentation page.

Once connected, the account address is displayed in the purchase panel:

Docusaurus with Keytar

If the Thanos wallet is not installed (as a browser extension), then the "Install Thanos" button is displayed.

Escrow origination

A payment contract is originated by the purchaser to start the purchase process. It supposes the seller is equipped with a contract indexer to be notified when a new purchase contract is originated.

Click the "Create escrow" button to trigger the contract creation (aka origination):

Docusaurus with Keytar

In this example, the following parameters are hardcoded in the contract:

  • seller address
  • tax collector address
  • tax rate
  • security deposit (equal to 110% of the face value of the item)

The contract code is embedded in origination transaction's json parameter in the script section, split in code and storage sections.

This json format of the Michelson contract code (called Micheline) is generated by the Archetype compiler.

[
{
"kind":"origination"
"balance":"0"
"script":{
"code":[...]
"storage":{...}
}
}
]

Once created, the new contract address is displayed and links to the Better Call Dev indexer for inspection. For example:

Docusaurus with Keytar

Fund escrow

The newly created escrow contract needs to be funded for the purchase query to be completed. Click the 'Fund escrow' button:

Docusaurus with Keytar

The json's transaction parameter is displayed by clicking the Raw button:

[{
"kind":"transaction"
"to":"KT1Ta6tPZiY7299CRtEEoSByW56pz4jCc9vj"
"amount":195500000
"mutez":true
"parameter":{
"entrypoint":"fund"
"value":{
"prim":"Unit"
}
}
}]

Note that the amount transeferred 195500000 is in mutez unit, which is 195.5ꜩ as expected.

Once validated, the balance of the escrow is displayed:

Docusaurus with Keytar

Finalize purchase

When the escrow is funded, the seller may send the item to the buyer's address.

info

Note that only the buyer may transfer the fund to the seller. The incentive for the buyer to do so is to get back the security deposit. This may be done when the item is received.

In this example, the transit process is materialized with the following popup:

Docusaurus with Keytar

Fill in the buyer address and click on 'Set Address'. When the address is set, the transit takes a about 20 seconds for the sake of the demonstration.

When the transit is complete, you may click on the 'Transfer fund' button in order to:

  1. transfer 85ꜩ to the sellet
  2. transfer back the security deposit of 85ꜩ back to you
  3. transfer the tax to the tax collector
Docusaurus with Keytar

The complete entry point of the escrow contract is called. Below is an example of the 3 generated internal transactions as shown in Better call Dev indexer:

Docusaurus with Keytar