-
Notifications
You must be signed in to change notification settings - Fork 1
tezos zkchannel operations
- [
bls12_381_fr
:cid
] - [
bls12_381_fr
:close
] - [
string
:context_string
] - [
address
:cust_addr
] - [
mutez
:cust_bal
] - [
mutez
:cust_funding
] - [
key
:custPk
] - [
timestamp
:delay_expiry
] - [
bls12_381_g2
:g2
] - [
address
:merch_addr
] - [
mutez
:merch_bal
] - [
mutez
:merchFunding
] - [
key
:merch_pk
] - [
bls12_381_g2
:merchPk0
] - [
bls12_381_g2
:merchPk1
] - [
bls12_381_g2
:merchPk2
] - [
bls12_381_g2
:merchPk3
] - [
bls12_381_g2
:merchPk4
] - [
bls12_381_g2
:merchPk5
] - [
int
:self_delay
] - [
bytes
:rev_lock
] - [
nat
:status
]
The contract origination operation has the following format:
"kind": "origination",
"source": <cust_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"balance": "0",
"script": {
"code": <zkchannel_contract>,
"storage": <initial_storage>
}
<cust_addr>
is the customer's tz1 address and should match the cust_addr
field in the contract initial storage. This account will also be used to fund the channel. <zkchannel_contract>
The zkchannels contract in michelson. Initial storage arguments. The expected format of the storage is:
(Pair
(Pair
(Pair
(Pair <cid> <close>)
(Pair
<context_string>
(Pair <cust_addr> <cus_bal>)
)
)
(Pair
(Pair
<cust_funding>
(Pair <cust_pk> <delayExpiry>)
)
(Pair
<g2>
(Pair <merch_addr> <merch_bal>)
)
)
)
(Pair
(Pair
(Pair <merch_funding> <merch_pk>)
(Pair
<merchPk0>
(Pair <merchPk1> <merchPk2>)
)
)
(Pair
(Pair
<merchPk3>
(Pair <merchPk4> <merchPk5>)
)
(Pair
<rev_lock>
(Pair <self_delay> <status>)
)
)
)
)
Contract calls are transfer operations where the destination is the smart contract. Entrypoints can be specified in the transaction and any additional arguments can be included with the --arg
flag, "Unit"
is the default value for when there are no additional arguments.
In the following operations, <contract_id>
is the contract ID (KT1 address) of the zkChannel contract.
"kind": "transaction",
"source": <cust_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": <cust_funding>,
"destination": <contract_id>,
"parameters": {
"entrypoint": "addFunding",
"args": "Unit"
}
<cust_funding>
specifies the amount to be transferred to fund the contract in mutez. This amount must be exactly equal to the cust_funding
specified in the contract's initial storage.
"kind": "transaction",
"source": <cust_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": "0",
"destination": <contract_id>,
"parameters": {
"entrypoint": "reclaimFunding",
"args": "Unit"
}
"kind": "transaction",
"source": <merch_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": "0",
"destination": <contract_id>,
"parameters": {
"entrypoint": "expiry",
"args": "Unit"
}
"kind": "transaction",
"source": <cust_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": <cust_funding>,
"destination": <contract_id>,
"parameters": {
"entrypoint": "custClose",
"args":
}
The arguments passed into custClose
are:
- the closing balances, [
mutez
:cust_bal
] and [mutez
:merch_bal
], - the revocation lock for that state, [
bytes
:rev_lock
], - and the merchant's closing authorization signature, [
bls12_381_g1
:s1
] and [bls12_381_g1
:s2
].
The expected format for <cust_close_storage>
is:
(Pair
(Pair <cust_bal> <merch_bal>)
(Pair
<rev_lock>
(Pair <s1> <s2>))
)
"kind": "transaction",
"source": <merch_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": "0",
"destination": <contract_id>,
"parameters": {
"entrypoint": "merchDispute",
"args": <revocation_secret>
}
[bytes
:revocation_secret
] is the SHA3 preimage for rev_lock
that had been broadcasted by the customer as part of the custClose
entrypoint call.
"kind": "transaction",
"source": <cust_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": "0",
"destination": <contract_id>,
"parameters": {
"entrypoint": "custClaim",
"args": "Unit"
}
"kind": "transaction",
"source": <cust_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": "0",
"destination": <contract_id>,
"parameters": {
"entrypoint": "merchClaim",
"args": "Unit"
}
"kind": "transaction",
"source": <cust_addr>,
"fee": <fee>,
"counter": <counter>,
"gas_limit": <gas_limit>,
"storage_limit": <storage_limit>,
"amount": "0",
"destination": <contract_id>,
"parameters": {
"entrypoint": "mutualClose",
"args": <mutual_close_storage>
}
<mutual_close_storage>
contains the closing balances that have been agreed upon by the customer and merchant, [mutez
:cust_bal
] and [mutez
:merch_bal
], and the merchant's EdDSA signature, [signature
:merch_sig
]. The expected format for <mutual_close_storage>
is:
(Pair
<cust_bal>
(Pair <merch_bal> <merch_sig>)
)