In ancient times, there was a legendary inscription that possessed immense spiritual power, yet its energy seemed to be out of place in that era. To prevent this power from causing havoc in the mortal realm, the gods joined forces to seal its power away. For millions of time block, it lay quietly among the ruins of the gods' temple, amidst a pile of rubble, devoid of any vitality. Until block 793000...
Rule
There is no initial allocation, all tokens are generated through minting.
Anyone can mint since block height 793000 (around June 5 18:00 UTC) until block height 800000.
The first 100 inscriptions of every 10 blocks are considered valid.
The maximum limit for each individual inscription is 1000 tokens, and the reward halves every 144 blocks until the individual reward decreases to 125 tokens. After that, the reward remains unchanged until reach max supply.
Minting will stop when the total number of tokens reaches 21,000,000.
If there is any discrepancy between above textual description and the actual results of the code, the results of the code should be considered authoritative.
Deployment
{
"p": "brc-20c",
"tick": "oicp",
"op": "deploy",
"donation": "bc1q8lweg0c8pthyuhlsaxhjt4sf056cxg6k6gz8lz",
"code": {
"engine": "trino",
"version": "386",
"body": "with inputs as( select block_height, tx_id, array_join(witness_data,',') payload from bitcoin.inputs t where t.block_height>=793000 and t.block_height<800000 and t.index=0), txns as ( select t.id txid, t.index from bitcoin.transactions t where t.block_height>=793000 and t.block_height<800000 ), rawdata as ( SELECT '{' || from_utf8( from_hex( substr( payload, position('2270223a226272632d3230' in payload), position('7d68' in payload) - position('2270223a226272632d3230' in payload) ) ) ) || '}' as body, block_height, t.tx_id as txid FROM inputs t WHERE 1=1 AND t.payload LIKE '%0063036f726401%' AND t.payload LIKE '%2270223a226272632d3230%' AND t.payload LIKE '%227469636b223a226f69637022%' ), formatted as ( select *, COALESCE(TRY(JSON_PARSE(body)), NULL) as data from rawdata ), parsed as ( SELECT t.txid, block_height, json_extract_scalar(t.data, '$.p') as p, json_extract_scalar(t.data, '$.tick') as tick, json_extract_scalar(t.data, '$.op') as op, COALESCE( TRY( CAST (json_extract_scalar(t.data, '$.amt') AS integer) ), 0 ) as amt FROM formatted t where t.data is not null ), filtered as ( select * from parsed t where (t.p='brc-20' or t.p='brc-20c') and t.tick='oicp' and t.op='mint' and t.amt>0 and t.amt<=1000 ), integrated as ( select t.*, f.index from filtered t join txns f on t.txid=f.txid ), sequenced as ( select row_number() OVER (ORDER BY t.block_height ASC,t.index ASC) as seq, t.* from integrated t ), decodes as ( select * from sequenced order by seq asc ), temp1 as ( select ROW_NUMBER() OVER (PARTITION BY block_height/10 ORDER BY seq ASC) emission, * from decodes t where t.block_height>=793000 AND t.amt<=CASE WHEN 1000/POWER(2,(block_height-793000)/144) > 125 THEN 1000/POWER(2,(block_height-793000)/144) ELSE 125 END ), temp2 as ( select SUM(t.amt) over (order by seq) as supply, * from temp1 t where t.emission<=100 order by seq ASC ), oicp as ( select * from temp2 t where t.supply<2100*10000 )"
},
"oops": {
"mint": "select * from oicp"
}
}
Inscription ID #10835888
Donation
The inclusion of the "Donation" field in the deployment was initially intended for demonstrating a conditional whitelist. However, it was later realized that such an approach might not be considered cool. If you appreciate this protocol, you are welcome to make a donation within your means. However, please do not expect any form of return or compensation.
Mint
In this example, both "p":"brc-20" and "p":"brc-20c" will be considered valid in order to demonstrate compatibility.
To prevent mint actions from being indexed by the indexer of the BRC-20 protocol and generating unnecessary transactions, we have specifically deployed an OICP token based on the BRC-20 protocol with the "max" and "limit" set to 0. In other words, all mint actions will only be indexed by future indexer implementations that support the BRC-20C protocol. Please be aware of this.
emmm, i suppose the code is quite straightforward and easy to understand, anything i need to explain?
with inputs as (
select block_height, tx_id, array_join(witness_data,',') payload
from
bitcoin.inputs t
where t.block_height>=793000 and t.block_height<800000 and t.index=0
),
txns as (
select t.id txid,
t.index
from bitcoin.transactions t
where t.block_height>=793000 and t.block_height<800000
),
rawdata as (
SELECT
'{' || from_utf8(
from_hex(
substr(
payload,
position('2270223a226272632d3230' in payload),
position('7d68' in payload) - position('2270223a226272632d3230' in payload)
)
)
) || '}' as body,
block_height,
t.tx_id as txid
FROM inputs t
WHERE 1=1
AND t.payload LIKE '%0063036f726401%'
AND t.payload LIKE '%2270223a226272632d3230%'
AND t.payload LIKE '%227469636b223a226f69637022%'
),
formatted as (
select *, COALESCE(TRY(JSON_PARSE(body)), NULL) as data from rawdata
),
parsed as (
SELECT t.txid,
block_height,
json_extract_scalar(t.data, '$.p') as p,
json_extract_scalar(t.data, '$.tick') as tick,
json_extract_scalar(t.data, '$.op') as op,
COALESCE(
TRY(
CAST (json_extract_scalar(t.data, '$.amt') AS integer)
),
0
) as amt
FROM formatted t
where t.data is not null
),
filtered as (
select * from parsed t where (t.p='brc-20' or t.p='brc-20c') and t.tick='oicp' and t.op='mint' and t.amt>0 and t.amt<=1000
),
integrated as (
select
t.*, f.index
from
filtered t
join
txns f on t.txid=f.txid
),
sequenced as (
select
row_number() OVER (ORDER BY t.block_height ASC,t.index ASC) as seq,
t.*
from
integrated t
),
decodes as (
select * from sequenced order by seq asc
),
temp1 as (
select ROW_NUMBER() OVER (PARTITION BY block_height/10 ORDER BY seq ASC) emission, * from decodes t
where
t.block_height>=793000
AND
t.amt<=CASE WHEN 1000/POWER(2,(block_height-793000)/144) > 125 THEN 1000/POWER(2,(block_height-793000)/144) ELSE 125 END
),
temp2 as (
select SUM(t.amt) over (order by seq) as supply, * from temp1 t
where
t.emission<=100
order by seq ASC
),
oicp as (
select * from temp2 t where t.supply<2100*10000
)
Further work
OICP has many more interesting feature waiting to be explored, such as the polymorphism mentioned earlier, which has not been fully demonstrated in this example. Additionally, intelligent conditions can become even more interesting. Anyway, have fun and look forward.
As we discussed in the previous , the upper-layer protocol inherits all the behaviors of the lower-layer protocol by default. Therefore, in this case, except for the overridden operation "mint", brc-20c inherits all the operations from brc-20. So, for other operations, please refer to the original protocol documentation for more details.