Exchange
From XTZ to city coin
Your are going to London during the week end. You need to buy some London City Coin with XTZ (Tezos currency) to visit museums:
- Select 'XTZ' currency
- Enter the amount of XTZ to spend
- Select 'XLD' token
- Quantity of XLD to get in exchange of the XTZ amount
Click on the 'Exchange button'; the temple wallet popup is displayed:
The transaction parameter specifies a call to the smart contract's entry point exchange
:
[{
"kind":"transaction"
"to":"KT1J48AfBi8NwNaFQM1AXTvordRgSRJxK313"
"amount":144000000
"mutez":true
"parameter":{
"entrypoint":"exchange"
"value":{
"prim":"Pair"
"args":[{
"string":"XTZ"
} {
"prim":"Pair"
"args":[{
"int":"144000000"
} {
"prim":"Pair"
"args":[{
"string":"XLD"
} {
"int":"661"
}]
}]
}]
}
}
}]
This will generate a sub-transaction from the DEX contract to XLD FA 1.2 contract (see DApp presentation).
From city coin to city coin
It is time to come back to Paris. Exchange the XLD tokens you have not spent to XPA tokens:
- Select 'XLD' token
- Enter the quantity of XLD tokens
- Select 'XPA' token
- Quantity of XPA to get in exchange of the XLD amount
Click on the 'Exchange button'; the temple wallet popup is displayed:
[{
"kind":"transaction"
"to":"KT1H8JUiFbvEMycCuG5sZfCGHkN7vgfLAs3n"
"amount":0
"mutez":true
"parameter":{
"entrypoint":"approve"
"value":{
"prim":"Pair"
"args":[{
"string":"KT1J48AfBi8NwNaFQM1AXTvordRgSRJxK313"
} {
"int":"6"
}]
}
}
} {
"kind":"transaction"
"to":"KT1J48AfBi8NwNaFQM1AXTvordRgSRJxK313"
"amount":0
"mutez":true
"parameter":{
"entrypoint":"exchange"
"value":{
"prim":"Pair"
"args":[{
"string":"XLD"
} {
"prim":"Pair"
"args":[{
"int":"6"
} {
"prim":"Pair"
"args":[{
"string":"XPA"
} {
"int":"16"
}]
}]
}]
}
}
}]
We note that two transactions are generated:
- a call to the
approve
entry point of the XLD FA 1.2 smart contract to authorize the DEX to transfer XLD ownership - a call to the
exchange
entry point of the DEX smart contract