1
1
```
2
2
LNPBP: 0020
3
3
Vertical: Smart contracts
4
- Title: RGB fungible assets schema (RGB-20)
4
+ Title: RGB fungible assets interface (RGB-20)
5
5
Authors: Dr Maxim Orlovsky <orlovsky@protonmail.ch>,
6
6
Giacomo Zucco,
7
7
Marco Amadori,
@@ -10,244 +10,122 @@ Authors: Dr Maxim Orlovsky <orlovsky@protonmail.ch>,
10
10
Sabina Sachtachtinskagia,
11
11
Martino Salvetti
12
12
Comments-URI: <https://github.com/LNP-BP/LNPBPs/issues/70>
13
- Status: Final
13
+ Status: Proposal
14
14
Type: Standards Track
15
15
Created: 2019-09-23
16
- Finalized: 2020-10-10
16
+ Finalized: 2022-12-18
17
17
License: CC0-1.0
18
18
```
19
19
20
- Schema ID: ` sch19s8js2gyxvtyzztp82l4tt4gr3x8m28yrgks93exsfuwc5u4fqlqf46ah5 `
21
-
22
- Encoded schema data: ` schema1qxx4qkgjsgcqcl2atrzgmugynnpuk7q5c7dcplkppl9jr0ywx75xnk3zyvup3p3ke99auju22h9734efqs6gfppkg6qcyy69a8uhnw7czt37ckszd950xwwn9mjr59payf3sd2yuezjdy5vu5jdkew7mr78prvvnjkg0x34qyf6fdfsxyd4fk6guzrpuuxp7exgkyhlntx8ruw9j2s2e7dt8sgjhczjkk5e2a3np886u86mq5ge92r5ckde9gr4htt2td66gkzvypm2hwpsr8gdm6vqzmgca3ltn8j0qqkd0rl5s6f3nllngjfldlt7kz7uarne8w0zkhwpr90k0smcxk48dx `
23
-
24
- Schema source:
25
- ``` rust
26
- Schema {
27
- rgb_features : none! (),
28
- root_id : none! (),
29
- genesis : GenesisSchema {
30
- metadata : type_map! {
31
- FieldType :: Ticker => Once ,
32
- FieldType :: Name => Once ,
33
- FieldType :: ContractText => NoneOrOnce ,
34
- FieldType :: Precision => Once ,
35
- FieldType :: Timestamp => Once ,
36
- FieldType :: IssuedSupply => Once
37
- },
38
- owned_rights : type_map! {
39
- OwnedRightsType :: Inflation => NoneOrMore ,
40
- OwnedRightsType :: Epoch => NoneOrOnce ,
41
- OwnedRightsType :: Assets => NoneOrMore ,
42
- OwnedRightsType :: Renomination => NoneOrOnce
43
- },
44
- public_rights : none! (),
45
- abi : none! (),
46
- },
47
- extensions : none! (),
48
- transitions : type_map! {
49
- TransitionType :: Issue => TransitionSchema {
50
- metadata : type_map! {
51
- FieldType :: IssuedSupply => Once
52
- },
53
- closes : type_map! {
54
- OwnedRightsType :: Inflation => Once
55
- },
56
- owned_rights : type_map! {
57
- OwnedRightsType :: Inflation => NoneOrMore ,
58
- OwnedRightsType :: Epoch => NoneOrOnce ,
59
- OwnedRightsType :: Assets => NoneOrMore
60
- },
61
- public_rights : none! (),
62
- abi : bmap! {
63
- // sum(in(inflation)) >= sum(out(inflation), out(assets))
64
- TransitionAction :: Validate => Procedure :: Embedded (StandardProcedure :: FungibleInflation )
65
- }
66
- },
67
- TransitionType :: Transfer => TransitionSchema {
68
- metadata : type_map! {},
69
- closes : type_map! {
70
- OwnedRightsType :: Assets => NoneOrMore
71
- },
72
- owned_rights : type_map! {
73
- OwnedRightsType :: Assets => NoneOrMore
74
- },
75
- public_rights : none! (),
76
- abi : none! ()
77
- },
78
- TransitionType :: Epoch => TransitionSchema {
79
- metadata : none! (),
80
- closes : type_map! {
81
- OwnedRightsType :: Epoch => Once
82
- },
83
- owned_rights : type_map! {
84
- OwnedRightsType :: Epoch => NoneOrOnce ,
85
- OwnedRightsType :: BurnReplace => NoneOrOnce
86
- },
87
- public_rights : none! (),
88
- abi : none! ()
89
- },
90
- TransitionType :: Burn => TransitionSchema {
91
- metadata : type_map! {
92
- FieldType :: BurnedSupply => Once ,
93
- // Normally issuer should aggregate burned assets into a
94
- // single UTXO; however if burn happens as a result of
95
- // mistake this will be impossible, so we allow to have
96
- // multiple burned UTXOs as a part of a single operation
97
- FieldType :: BurnUtxo => OnceOrUpTo (None ),
98
- FieldType :: HistoryProofFormat => Once ,
99
- FieldType :: HistoryProof => NoneOrMore ,
100
- },
101
- closes : type_map! {
102
- OwnedRightsType :: BurnReplace => Once
103
- },
104
- owned_rights : type_map! {
105
- OwnedRightsType :: BurnReplace => NoneOrOnce
106
- },
107
- public_rights : none! (),
108
- abi : bmap! {
109
- TransitionAction :: Validate => Procedure :: Embedded (StandardProcedure :: ProofOfBurn )
110
- }
111
- },
112
- TransitionType :: BurnAndReplace => TransitionSchema {
113
- metadata : type_map! {
114
- FieldType :: BurnedSupply => Once ,
115
- // Normally issuer should aggregate burned assets into a
116
- // single UTXO; however if burn happens as a result of
117
- // mistake this will be impossible, so we allow to have
118
- // multiple burned UTXOs as a part of a single operation
119
- FieldType :: BurnUtxo => OnceOrMore ,
120
- FieldType :: HistoryProofFormat => Once ,
121
- FieldType :: HistoryProof => NoneOrMore
122
- },
123
- closes : type_map! {
124
- OwnedRightsType :: BurnReplace => Once
125
- },
126
- owned_rights : type_map! {
127
- OwnedRightsType :: BurnReplace => NoneOrOnce ,
128
- OwnedRightsType :: Assets => OnceOrMore
129
- },
130
- public_rights : none! (),
131
- abi : bmap! {
132
- TransitionAction :: Validate => Procedure :: Embedded (StandardProcedure :: ProofOfBurn )
133
- }
134
- },
135
- TransitionType :: Renomination => TransitionSchema {
136
- metadata : type_map! {
137
- FieldType :: Ticker => NoneOrOnce ,
138
- FieldType :: Name => NoneOrOnce ,
139
- FieldType :: ContractText => NoneOrOnce ,
140
- FieldType :: Precision => NoneOrOnce
141
- },
142
- closes : type_map! {
143
- OwnedRightsType :: Renomination => Once
144
- },
145
- owned_rights : type_map! {
146
- OwnedRightsType :: Renomination => NoneOrOnce
147
- },
148
- public_rights : none! (),
149
- abi : none! ()
150
- },
151
- // Allows split of rights if they were occasionally allocated to the
152
- // same UTXO, for instance both assets and issuance right. Without
153
- // this type of transition either assets or inflation rights will be
154
- // lost.
155
- TransitionType :: RightsSplit => TransitionSchema {
156
- metadata : none! (),
157
- closes : type_map! {
158
- OwnedRightsType :: Inflation => NoneOrMore ,
159
- OwnedRightsType :: Assets => NoneOrMore ,
160
- OwnedRightsType :: Epoch => NoneOrOnce ,
161
- OwnedRightsType :: BurnReplace => NoneOrOnce ,
162
- OwnedRightsType :: Renomination => NoneOrOnce
163
- },
164
- owned_rights : type_map! {
165
- OwnedRightsType :: Inflation => NoneOrMore ,
166
- OwnedRightsType :: Assets => NoneOrMore ,
167
- OwnedRightsType :: Epoch => NoneOrOnce ,
168
- OwnedRightsType :: BurnReplace => NoneOrOnce ,
169
- OwnedRightsType :: Renomination => NoneOrOnce
170
- },
171
- public_rights : none! (),
172
- abi : bmap! {
173
- // We must allocate exactly one or none rights per each
174
- // right used as input (i.e. closed seal); plus we need to
175
- // control that sum of inputs is equal to the sum of outputs
176
- // for each of state types having assigned confidential
177
- // amounts
178
- TransitionAction :: Validate => Procedure :: Embedded (StandardProcedure :: RightsSplit )
179
- }
180
- }
181
- },
182
- field_types : type_map! {
183
- // Rational: if we will use just 26 letters of English alphabet (and
184
- // we are not limited by them), we will have 26^8 possible tickers,
185
- // i.e. > 208 trillions, which is sufficient amount
186
- FieldType :: Ticker => DataFormat :: String (8 ),
187
- FieldType :: Name => DataFormat :: String (256 ),
188
- // Contract text may contain URL, text or text representation of
189
- // Ricardian contract, up to 64kb. If the contract doesn't fit, a
190
- // double SHA256 hash and URL should be used instead, pointing to
191
- // the full contract text, where hash must be represented by a
192
- // hexadecimal string, optionally followed by `\n` and text URL
193
- FieldType :: ContractText => DataFormat :: String (core :: u16 :: MAX ),
194
- FieldType :: Precision => DataFormat :: Unsigned (Bits :: Bit8 , 0 , 18u128 ),
195
- // We need this b/c allocated amounts are hidden behind Pedersen
196
- // commitments
197
- FieldType :: IssuedSupply => DataFormat :: Unsigned (Bits :: Bit64 , 0 , core :: u64 :: MAX as u128 ),
198
- // Supply in either burn or burn-and-replace procedure
199
- FieldType :: BurnedSupply => DataFormat :: Unsigned (Bits :: Bit64 , 0 , core :: u64 :: MAX as u128 ),
200
- // While UNIX timestamps allow negative numbers; in context of RGB
201
- // Schema, assets can't be issued in the past before RGB or Bitcoin
202
- // even existed; so we prohibit all the dates before RGB release
203
- // This timestamp is equal to 10/10/2020 @ 2:37pm (UTC)
204
- FieldType :: Timestamp => DataFormat :: Integer (Bits :: Bit64 , 1602340666 , core :: i64 :: MAX as i128 ),
205
- FieldType :: HistoryProof => DataFormat :: Bytes (core :: u16 :: MAX ),
206
- FieldType :: HistoryProofFormat => DataFormat :: Enum (HistoryProofFormat :: all ()),
207
- FieldType :: BurnUtxo => DataFormat :: TxOutPoint
208
- },
209
- owned_right_types : type_map! {
210
- OwnedRightsType :: Inflation => StateSchema {
211
- // How much issuer can issue tokens on this path. If there is no
212
- // limit, than `core::u64::MAX` / sum(inflation_assignments)
213
- // must be used, as this will be a de-facto limit to the
214
- // issuance
215
- format : StateFormat :: CustomData (DataFormat :: Unsigned (Bits :: Bit64 , 0 , core :: u64 :: MAX as u128 )),
216
- // Validation involves other state data, so it is performed
217
- // at the level of `issue` state transition
218
- abi : none! ()
219
- },
220
- OwnedRightsType :: Assets => StateSchema {
221
- format : StateFormat :: DiscreteFiniteField (DiscreteFiniteFieldFormat :: Unsigned64bit ),
222
- abi : bmap! {
223
- // sum(inputs) == sum(outputs)
224
- AssignmentAction :: Validate => Procedure :: Embedded (StandardProcedure :: NoInflationBySum )
225
- }
226
- },
227
- OwnedRightsType :: Epoch => StateSchema {
228
- format : StateFormat :: Declarative ,
229
- abi : none! ()
230
- },
231
- OwnedRightsType :: BurnReplace => StateSchema {
232
- format : StateFormat :: Declarative ,
233
- abi : none! ()
234
- },
235
- OwnedRightsType :: Renomination => StateSchema {
236
- format : StateFormat :: Declarative ,
237
- abi : none! ()
238
- }
239
- },
240
- public_right_types : none! (),
241
- }
20
+ - [ Abstract] ( #abstract )
21
+ - [ Background] ( #background )
22
+ - [ Motivation] ( #motivation )
23
+ - [ Design] ( #design )
24
+ - [ Specification] ( #specification )
25
+ - [ Compatibility] ( #compatibility )
26
+ - [ Rationale] ( #rationale )
27
+ - [ Reference implementation] ( #reference-implementation )
28
+ - [ Acknowledgements] ( #acknowledgements )
29
+ - [ References] ( #references )
30
+ - [ Copyright] ( #copyright )
31
+
32
+
33
+ ## Abstract
34
+
35
+
36
+ ## Background
37
+
38
+
39
+ ## Motivation
40
+
41
+
42
+ ## Design
43
+
44
+
45
+
46
+ ## Specification
47
+
48
+ Interface specification is the following Contractum code:
49
+
50
+ ``` haskell
51
+ -- # Defining main data structures
52
+
53
+ -- number of decimal fractions (decimal numbers after floating point)
54
+ data DecFractions :: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
55
+ 14 | 15 | 16 | 17 | 18
56
+
57
+ data TxOut :: txid [Byte ^ 32 ], vout U16
58
+
59
+ data Amount :: U64 -- asset amount
60
+
61
+ -- allocation of assets to some transactou output
62
+ data Allocation :: TxOut , Amount
63
+
64
+ -- right over certain amount of assets; right owner may be unknown
65
+ data AssetControl :: TxOut ? , Amount
66
+
67
+ data Nomination ::
68
+ ticker [Ascii ^ 1 .. 8 ],
69
+ name [Ascii ^ 1 .. 40 ],
70
+ details [Unicode ^ 40 .. 256 ]? ,
71
+ contract [Unicode ]?? ,
72
+ precision DecFractions
73
+
74
+ data RGB20Info ::
75
+ knownInfo Nomination ,
76
+ origInfo Nomination ,
77
+ isFinalInfo Bool ,
78
+ renominationRight TxOut ? ,
79
+
80
+ isSupplyKnown Bool , -- indicates that all issues, burn and reissues are known
81
+ supplyKnown Amount , -- returns information about known cirtulating supply
82
+ supplyLimit Amount , -- maximum possible asset inflation
83
+ pastIssues [AssetControl ], -- known past issue operations
84
+ futureIssues [AssetControl ], -- known future issue operations
85
+ knownBurns [AssetControl ], -- known past burn operations
86
+ knownReissues [AssetControl ], -- known future burn operations
87
+
88
+ knownAllocations [Allocation ] -- known asset amounts allocated to known UTXOs
89
+
90
+ interface RGB20 :: RGB20Info
91
+ op transfer :: inputs [TxOut ^ 1 .. ]
92
+ -> beneficiaries [Allocation ]
93
+
94
+ -- question mark denotes optional operation, which may not be supported by
95
+ -- some of schemata implementing the intrface
96
+
97
+ op? issue :: usingRight TxOut , amount Amount
98
+ -> nextRight TxOut ? , beneficiaries [Allocation ]
99
+
100
+ op? burn :: usingRight TxOut , assets Allocation
101
+ -> nextRight TxOut ?
102
+
103
+ op? reissue :: usingRight TxOut , assets Allocation
104
+ -> nextRight TxOut ? , beneficiaries [Allocation ]
105
+
106
+ op? renominate :: usingRight TxOut
107
+ -> nextRight TxOut ? , newNomination AssetInfo
242
108
```
243
109
244
- ## Subschemata
110
+ ## Compatibility
245
111
246
- - https://github.com/LNP-BP/LNPBPs/issues/44
247
112
248
113
## Rationale
249
114
250
115
Include from
251
116
- https://github.com/LNP-BP/LNPBPs/issues/27
252
117
- https://github.com/LNP-BP/LNPBPs/issues/28
253
118
- https://github.com/LNP-BP/LNPBPs/issues/50
119
+
120
+ ## Reference implementation
121
+
122
+
123
+ ## Acknowledgements
124
+
125
+
126
+ ## References
127
+
128
+
129
+ ## Copyright
130
+
131
+ This document is licensed under the Creative Commons CC0 1.0 Universal license.
0 commit comments