Storage

Storage

Storage

Short description

โ€‹exchange_states TMap(int, string)

Various states that an exchange can take.

โ€‹exchange_types TMap(string, nat)

Types of possible exchanges on SmartLink

โ€‹exchanges TMap(string, $exchange_object)

Record of all ongoing and past exchanges

โ€‹owner TAddress

Owner of the Escrow smart contract

โ€‹slashing_rate TNat

Global slashing rate for the SmartLink escrow process

exchange_states TMap(int, string)

Smart contract interaction
Smart contract interaction

exchange_states stores the various states that an exchange can take. In other words, it describes all the conducted steps during an exchange from its initialization to its validation. There are 4 steps in total. It is set at the contract origination and cannot be changed afterward.

Demo values

Id

State

0

WAITING_FOR_TRANSFER

1

WAITING_FOR_VALIDATION

2

VALIDATED

3

CANCELLED

exchange_types TMap(string, nat)

exchange_types stores the types of exchanges that are possible on SmartLink and their respecting commission percentage. The owner of the contract can add a new exchange type or update the commission percentage of an existing one through the updateExchangeType entry point.

Demo values

Type

Commission (%)

DOMAIN_NAME

3

OBJECT

2

OTHER

1

exchanges TMap(string, $exchange_object)

exchanges stores all the ongoing and past exchanges id and their related exchange_object containing the key information about the escrow and the exchange itself.

Each time a buyer puts an amount into escrow after buying an item on the marketplace or accepting a peer-to-peer offer, a new exchange is created. It is updated each time the exchange changes its state. An exchange is considered as finished when it gets the state VALIDATED (2).

Exchange object

Key

Value type

Short description

buyer

TAddress

Tezos address of the buyer

seller

TAddress

Tezos address of the seller

name

TString

Name of the exchanged item

exchange_type

TString

Type of the exchange matching those stored in exchange_types map.

state

TString

Current state of the exchange

last_update

TTimeStamp

Date of the last exchange update corresponding to the last state change.

total_escrow

Object

Amount put in escrow by the seller. It is made of 4 values:

  • asked_price TMutez: price asked by the seller

  • commission TMutez: commission amount of the item

  • escrow TMutez: amount put in escrow by the buyer

  • slashing TMutez: amount of the slashing given back if the buyer validates the exchange at the end

  • shipping TMutez: shipping price

owner TAddress

owner stores the Tezos address of the owner of the escrow contract. In the Demo, the owner of the contract is the address used to originate the contract. This state variable can be changed only by the current owner who can set a new address with the setOwner entry point.

slashing_rate TNat

slashing_rate is set at the contract origination and cannot be changed afterward (in the demo version). It is a percentage of the asked price by the seller that is put into escrow by the seller to incentivize them to validate the exchange at the end: if everything goes right and they validate the exchange, they get the slashing amount. The slashing rate is global: it does not change whether the buyer is buying an item on the marketplace or accepting a peer-to-peer offer. It also does not differ with the exchange type.