From 5074aadd6a03c6e4396de0b5546c9cca24b04b9f Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 5 Feb 2024 12:10:35 -0800 Subject: [PATCH 01/16] add `MINT_ADDRESS_MAX` note --- docs/actions/ISSUE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/actions/ISSUE.md b/docs/actions/ISSUE.md index fc8d52e..eb6996d 100644 --- a/docs/actions/ISSUE.md +++ b/docs/actions/ISSUE.md @@ -128,6 +128,7 @@ This example issues a TEST token with a max supply of 100, and a maximum mint of - By default any address can interact with a BTNS token, to change this behavior use `ALLOW_LIST` and `BLOCK_LIST` - If `TICK` contains any unicode characters, then `TICK` should be `base64` encoded - `counterparty` `ASSET` and `SUBASSET` names are reserved within the BTNS for use by the `counterparty` owner +- `MINT_ADDRESS_MAX` can be used to limit the maximum `TICK` `AMOUNT` that a single address can `MINT` - `MINT_START_BLOCK` and `MINT_STOP_BLOCK` can be used to determine period(s) when `MINT` transactions are allowed - `MINT_FEE_TICK` and `MINT_FEE_AMOUNT` can be used to require a set `TICK` `AMOUNT` fee be paid on a MINT transaction - `MINT_FEE_ADDRESS` can be used to send `MINT` fees to an address instead of destroying the fee From c9ee7838040bc03062cae7df56c3c7f7ad09d3db Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 5 Feb 2024 14:42:43 -0800 Subject: [PATCH 02/16] support for `MINT_ADDRESS_MAX` --- indexer/includes/actions/issue.php | 15 +++++++-- indexer/includes/actions/mint.php | 13 ++++--- indexer/includes/functions.php | 54 ++++++++++++++++++++++-------- indexer/sql/issues.sql | 1 + indexer/sql/tokens.sql | 1 + 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index 1799ef6..4ca0889 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -23,6 +23,7 @@ * - CALLBACK_AMOUNT - `TICK` `token` amount that users get when `CALLBACK` command is used * - ALLOW_LIST - `TX_HASH` of a BTNS LIST of addresses allowed to interact with this token * - BLOCK_LIST - `TX_HASH` of a BTNS LIST of addresses NOT allowed to interact with this token + * - MINT_ADDRESS_MAX - Maximum amount of supply any address can mint via `MINT` transactions * * FORMATS : * - 0 = Full @@ -37,16 +38,16 @@ function btnsIssue( $params=null, $data=null, $error=null){ // Define list of known FORMATS $formats = array( - 0 => 'VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST', + 0 => 'VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST|MINT_ADDRESS_MAX', 1 => 'VERSION|TICK|DESCRIPTION', - 2 => 'VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY', + 2 => 'VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY|MINT_ADDRESS_MAX', 3 => 'VERSION|TICK|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK', 4 => 'VERSION|TICK|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK' ); // Define list of AMOUNT and LOCK fields (used in validations) $fieldList = array( - 'AMOUNT' => array('MAX_SUPPLY','MAX_MINT','MINT_SUPPLY','CALLBACK_AMOUNT'), + 'AMOUNT' => array('MAX_SUPPLY','MAX_MINT','MINT_SUPPLY','CALLBACK_AMOUNT','MINT_ADDRESS_MAX'), 'LOCK' => array('LOCK_SUPPLY', 'LOCK_MINT', 'LOCK_DESCRIPTION', 'LOCK_RUG', 'LOCK_SLEEP', 'LOCK_CALLBACK') ); @@ -192,6 +193,14 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && isset($data->MINT_SUPPLY) && $data->MINT_SUPPLY > $data->MAX_SUPPLY) $error = 'invalid: MINT_SUPPLY > MAX_SUPPLY'; + // Verify MINT_ADDRESS_MAX is less than MAX_SUPPLY + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > $data->MAX_SUPPLY) + $error = 'invalid: MINT_ADDRESS_MAX > MAX_SUPPLY'; + + // Verify MINT_ADDRESS_MAX is greater than than MAX_MINT + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX < $data->MAX_MINT) + $error = 'invalid: MINT_ADDRESS_MAX < MAX_MINT'; + // Verify MAX_SUPPLY can not be changed if LOCK_SUPPLY is enabled if(!$error && $btInfo && $btnInfo->LOCK_SUPPLY && isset($data->MAX_SUPPLY) && $data->MAX_SUPPLY!=$btnInfo->MAX_SUPPLY) $error = 'invalid: MAX_SUPPLY (locked)'; diff --git a/indexer/includes/actions/mint.php b/indexer/includes/actions/mint.php index e5e1320..d637806 100644 --- a/indexer/includes/actions/mint.php +++ b/indexer/includes/actions/mint.php @@ -51,10 +51,11 @@ function btnsMint($params=null, $data=null, $error=null){ // Update BTNS transaction object with basic token details if($btInfo){ - $data->SUPPLY = ($btInfo) ? $btInfo->SUPPLY : 0; - $data->DECIMALS = ($btInfo) ? $btInfo->DECIMALS : 0; - $data->MAX_SUPPLY = ($btInfo) ? $btInfo->MAX_SUPPLY : 0; - $data->MAX_MINT = ($btInfo) ? $btInfo->MAX_MINT : 0; + $data->SUPPLY = ($btInfo) ? $btInfo->SUPPLY : 0; + $data->DECIMALS = ($btInfo) ? $btInfo->DECIMALS : 0; + $data->MAX_SUPPLY = ($btInfo) ? $btInfo->MAX_SUPPLY : 0; + $data->MAX_MINT = ($btInfo) ? $btInfo->MAX_MINT : 0; + $data->MINT_ADDRESS_MAX = ($btInfo) ? $btInfo->MINT_ADDRESS_MAX : 0; } /***************************************************************** @@ -89,6 +90,10 @@ function btnsMint($params=null, $data=null, $error=null){ if(!$error && isset($data->DESTINATION) && !isActionAllowed($data->TICK, $data->DESTINATION)) $error = 'invalid: DESTINATION (not authorized)'; + // Verify minting AMOUNT will not exceed MINT_ADDRESS_MAX + if(!$error && $data->MINT_ADDRESS_MAX > 0 && (bcadd(getActionCreditDebitAmount('credits', 'MINT', $data->TICK, $data->SOURCE),$data->AMOUNT,$data->DECIMALS) > $data->MINT_ADDRESS_MAX)) + $error = 'invalid: mint exceeds MINT_ADDRESS_MAX'; + // Determine final status $data->STATUS = $status = ($error) ? $error : 'valid'; diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index 2149941..987b6db 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -219,20 +219,23 @@ function createIssue( $data=null ){ $max_supply = (isset($data->MAX_SUPPLY) && is_numeric($data->MAX_SUPPLY)) ? $data->MAX_SUPPLY : 0; $max_mint = (isset($data->MAX_MINT) && is_numeric($data->MAX_MINT)) ? $data->MAX_MINT : 0; $mint_supply = (isset($data->MINT_SUPPLY) && is_numeric($data->MINT_SUPPLY)) ? $data->MINT_SUPPLY : 0; + $mint_address_max = (isset($data->MINT_ADDRESS_MAX) && is_numeric($data->MINT_ADDRESS_MAX)) ? $data->MINT_ADDRESS_MAX : 0; $callback_amount = (isset($data->CALLBACK_AMOUNT) && is_numeric($data->CALLBACK_AMOUNT)) ? $data->CALLBACK_AMOUNT : 0; $decimals = (isset($data->DECIMALS)) ? $data->DECIMALS : 0; // Truncate description to 250 chars $description = substr($data->DESCRIPTION,0,250); // Force any amount values to the correct decimal precision if(is_numeric($decimals) && $decimals>=0 && $decimals<=18){ - $max_supply = bcmul($max_supply,1,$decimals); - $max_mint = bcmul($max_mint,1,$decimals); - $mint_supply = bcmul($mint_supply,1,$decimals); - $callback_amount = bcmul($callback_amount,1,$decimals); + $max_supply = bcmul($max_supply,1,$decimals); + $max_mint = bcmul($max_mint,1,$decimals); + $mint_supply = bcmul($mint_supply,1,$decimals); + $mint_address_max = bcmul($mint_address_max,1,$decimals); + $callback_amount = bcmul($callback_amount,1,$decimals); } $max_supply = $mysqli->real_escape_string($max_supply); $max_mint = $mysqli->real_escape_string($max_mint); $mint_supply = $mysqli->real_escape_string($mint_supply); + $mint_address_max = $mysqli->real_escape_string($mint_address_max); $decimals = $mysqli->real_escape_string($decimals); $description = $mysqli->real_escape_string($description); $block_index = $mysqli->real_escape_string($data->BLOCK_INDEX); @@ -285,6 +288,7 @@ function createIssue( $data=null ){ callback_amount='{$callback_amount}', allow_list_id='{$allow_list_id}', block_list_id='{$block_list_id}', + mint_address_max='{$mint_address_max}', source_id='{$source_id}', block_index='{$block_index}', tx_index='{$tx_index}', @@ -293,14 +297,14 @@ function createIssue( $data=null ){ tx_hash_id='{$tx_hash_id}'"; } else { // INSERT record - $sql = "INSERT INTO issues (tick_id, max_supply, max_mint, decimals, description, mint_supply, transfer_id, transfer_supply_id, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, source_id, tx_hash_id, block_index, tx_index, status_id) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$mint_supply}', '{$transfer_id}', '{$transfer_supply_id}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}','{$source_id}', '{$tx_hash_id}', '{$block_index}', '{$tx_index}', '{$status_id}')"; + $sql = "INSERT INTO issues (tick_id, max_supply, max_mint, decimals, description, mint_supply, transfer_id, transfer_supply_id, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, source_id, tx_hash_id, block_index, tx_index, status_id) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$mint_supply}', '{$transfer_id}', '{$transfer_supply_id}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$source_id}', '{$tx_hash_id}', '{$block_index}', '{$tx_index}', '{$status_id}')"; } // print $sql; $results = $mysqli->query($sql); if(!$results) - byeLog('Error while trying to create / update a record in the deploys table'); + byeLog('Error while trying to create / update a record in the issues table'); } else { - byeLog('Error while trying to lookup record in deploys table'); + byeLog('Error while trying to lookup record in issues table'); } } @@ -457,18 +461,21 @@ function createToken( $data=null ){ $max_supply = (isset($data->MAX_SUPPLY) && is_numeric($data->MAX_SUPPLY)) ? $data->MAX_SUPPLY : 0; $max_mint = (isset($data->MAX_MINT) && is_numeric($data->MAX_MINT)) ? $data->MAX_MINT : 0; $mint_supply = (isset($data->MINT_SUPPLY) && is_numeric($data->MINT_SUPPLY)) ? $data->MINT_SUPPLY : 0; + $mint_address_max = (isset($data->MINT_ADDRESS_MAX) && is_numeric($data->MINT_ADDRESS_MAX)) ? $data->MINT_ADDRESS_MAX : 0; $callback_amount = (isset($data->CALLBACK_AMOUNT) && is_numeric($data->CALLBACK_AMOUNT)) ? $data->CALLBACK_AMOUNT : 0; $decimals = (isset($data->DECIMALS)) ? $data->DECIMALS : 0; // Force any amount values to the correct decimal precision if(is_numeric($decimals) && $decimals>=0 && $decimals<=18){ - $max_supply = bcmul($max_supply,1,$decimals); - $max_mint = bcmul($max_mint,1,$decimals); - $mint_supply = bcmul($mint_supply,1,$decimals); - $callback_amount = bcmul($callback_amount,1,$decimals); + $max_supply = bcmul($max_supply,1,$decimals); + $max_mint = bcmul($max_mint,1,$decimals); + $mint_supply = bcmul($mint_supply,1,$decimals); + $mint_address_max = bcmul($mint_address_max,1,$decimals); + $callback_amount = bcmul($callback_amount,1,$decimals); } $supply = $mysqli->real_escape_string($supply); $max_supply = $mysqli->real_escape_string($max_supply); $max_mint = $mysqli->real_escape_string($max_mint); + $mint_address_max = $mysqli->real_escape_string($mint_address_max); $decimals = $mysqli->real_escape_string($decimals); $description = $mysqli->real_escape_string($data->DESCRIPTION); $block_index = $mysqli->real_escape_string($data->BLOCK_INDEX); @@ -510,6 +517,7 @@ function createToken( $data=null ){ callback_amount='{$callback_amount}', allow_list_id='{$allow_list_id}', block_list_id='{$block_list_id}', + mint_address_max='{$mint_address_max}', block_index='{$block_index}', supply='{$supply}', owner_id='{$owner_id}' @@ -517,7 +525,7 @@ function createToken( $data=null ){ tick_id='{$tick_id}'"; } else { // INSERT record - $sql = "INSERT INTO tokens (tick_id, max_supply, max_mint, decimals, description, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, owner_id, supply, block_index) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$owner_id}','{$supply}', '{$block_index}')"; + $sql = "INSERT INTO tokens (tick_id, max_supply, max_mint, decimals, description, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, owner_id, supply, block_index) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$owner_id}','{$supply}', '{$block_index}')"; } // print $sql; $results = $mysqli->query($sql); @@ -920,6 +928,7 @@ function getTokenInfo($tick=null, $tick_id=null){ t1.callback_amount, t4.hash as allow_list, t5.hash as block_list, + t1.mint_address_max, a.address as owner FROM tokens t1 @@ -956,7 +965,8 @@ function getTokenInfo($tick=null, $tick_id=null){ 'CALLBACK_BLOCK' => $row->callback_block, 'CALLBACK_AMOUNT' => $row->callback_amount, 'ALLOW_LIST' => $row->allow_list, - 'BLOCK_LIST' => $row->block_list + 'BLOCK_LIST' => $row->block_list, + 'MINT_ADDRESS_MAX' => $row->mint_address_max ); } } else { @@ -1056,7 +1066,7 @@ function getTokenDecimalPrecision($tick_id=null){ } // Handle getting credits or debits records for a given address -function getAddressCreditDebit($table=null, $address=null){ +function getAddressCreditDebit($table=null, $address=null, $action=null){ global $mysqli; $data = array(); // Assoc array to store tick/credits $type = gettype($address); @@ -1064,6 +1074,8 @@ function getAddressCreditDebit($table=null, $address=null){ $address_id = $address; if($type==='string' && !is_numeric($address)) $address_id = createAddress($address); + if(isset($action)) + $action_id = createAction($action); if(in_array($table,array('credits','debits'))){ // Get data from the table $sql = "SELECT @@ -1076,6 +1088,8 @@ function getAddressCreditDebit($table=null, $address=null){ WHERE t2.tick_id=t1.tick_id AND t1.address_id='{$address_id}'"; + if(isset($action)) + $sql .= " AND t1.action_id={$action_id}"; $results = $mysqli->query($sql); if($results){ if($results->num_rows){ @@ -1755,4 +1769,16 @@ function consolidateCreditDebitRecords($type=null, $records=null){ } return $data; } + +// Get total amount of credit or debit records for a given address, ticker, and action +function getActionCreditDebitAmount($table=null, $action=null, $tick=null, $address=null){ + global $mysqli; + $total = 0; + $tick_id = createTicker($tick); + $addr_id = createAddress($address); + $data = getAddressCreditDebit($table, $addr_id, $action); + if($data[$tick_id]) + $total = $data[$tick_id]; + return $total; +} ?> \ No newline at end of file diff --git a/indexer/sql/issues.sql b/indexer/sql/issues.sql index ed08ec9..84ac91b 100644 --- a/indexer/sql/issues.sql +++ b/indexer/sql/issues.sql @@ -20,6 +20,7 @@ CREATE TABLE issues ( callback_amount VARCHAR(250), -- AMOUNT users get if CALLBACK allow_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table block_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table + mint_address_max VARCHAR(250), -- Maximum amount of supply an address can MINT source_id INTEGER UNSIGNED, -- id of record in index_addresses table (address that did DEPLOY) tx_hash_id INTEGER UNSIGNED, -- id of record in index_transactions block_index INTEGER UNSIGNED, -- block index of DEPLOY transaction diff --git a/indexer/sql/tokens.sql b/indexer/sql/tokens.sql index 1a8b5f0..1a5f8c8 100644 --- a/indexer/sql/tokens.sql +++ b/indexer/sql/tokens.sql @@ -19,6 +19,7 @@ CREATE TABLE tokens ( callback_amount BIGINT UNSIGNED, -- AMOUNT users get if CALLBACK allow_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table block_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table + mint_address_max VARCHAR(250), -- Maximum amount of supply an address can MINT owner_id INTEGER UNSIGNED, -- id of record in index_addresses table btc_price VARCHAR(250) NOT NULL default 0 -- last price of BTC purchase of 1 token ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; From 21a35bf40f9e12373f4540165ea75a24b857ac03 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 5 Feb 2024 15:34:41 -0800 Subject: [PATCH 03/16] tweak `MINT_ADDRESS_MAX ` validation logic --- indexer/includes/actions/mint.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indexer/includes/actions/mint.php b/indexer/includes/actions/mint.php index d637806..1995c70 100644 --- a/indexer/includes/actions/mint.php +++ b/indexer/includes/actions/mint.php @@ -90,8 +90,8 @@ function btnsMint($params=null, $data=null, $error=null){ if(!$error && isset($data->DESTINATION) && !isActionAllowed($data->TICK, $data->DESTINATION)) $error = 'invalid: DESTINATION (not authorized)'; - // Verify minting AMOUNT will not exceed MINT_ADDRESS_MAX - if(!$error && $data->MINT_ADDRESS_MAX > 0 && (bcadd(getActionCreditDebitAmount('credits', 'MINT', $data->TICK, $data->SOURCE),$data->AMOUNT,$data->DECIMALS) > $data->MINT_ADDRESS_MAX)) + // Verify minting AMOUNT will not exceed MINT_ADDRESS_MAX + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX && (bcadd(getActionCreditDebitAmount('credits', 'MINT', $data->TICK, $data->SOURCE),$data->AMOUNT,$data->DECIMALS) > $data->MINT_ADDRESS_MAX)) $error = 'invalid: mint exceeds MINT_ADDRESS_MAX'; // Determine final status From 750e44d588b242946f744896d94ce5fab7331f46 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 5 Feb 2024 18:33:54 -0800 Subject: [PATCH 04/16] support for `MINT_START_BLOCK` and `MINT_STOP_BLOCK` --- indexer/includes/actions/issue.php | 24 +++++++++++++++++++----- indexer/includes/actions/mint.php | 12 +++++++++++- indexer/includes/functions.php | 22 +++++++++++++++++++--- indexer/sql/issues.sql | 2 ++ indexer/sql/tokens.sql | 4 +++- 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index 4ca0889..49fd991 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -24,6 +24,8 @@ * - ALLOW_LIST - `TX_HASH` of a BTNS LIST of addresses allowed to interact with this token * - BLOCK_LIST - `TX_HASH` of a BTNS LIST of addresses NOT allowed to interact with this token * - MINT_ADDRESS_MAX - Maximum amount of supply any address can mint via `MINT` transactions + * - MINT_START_BLOCK - `BLOCK_INDEX` when `MINT` transactions are allowed (begin mint) + * - MINT_STOP_BLOCK` - `BLOCK_INDEX` when `MINT` transactions are NOT allowed (end mint) * * FORMATS : * - 0 = Full @@ -38,16 +40,16 @@ function btnsIssue( $params=null, $data=null, $error=null){ // Define list of known FORMATS $formats = array( - 0 => 'VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST|MINT_ADDRESS_MAX', + 0 => 'VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK', 1 => 'VERSION|TICK|DESCRIPTION', - 2 => 'VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY|MINT_ADDRESS_MAX', + 2 => 'VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK', 3 => 'VERSION|TICK|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK', 4 => 'VERSION|TICK|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK' ); // Define list of AMOUNT and LOCK fields (used in validations) $fieldList = array( - 'AMOUNT' => array('MAX_SUPPLY','MAX_MINT','MINT_SUPPLY','CALLBACK_AMOUNT','MINT_ADDRESS_MAX'), + 'AMOUNT' => array('MAX_SUPPLY', 'MAX_MINT', 'MINT_SUPPLY', 'CALLBACK_AMOUNT', 'MINT_ADDRESS_MAX', 'MINT_START_BLOCK', 'MINT_STOP_BLOCK'), 'LOCK' => array('LOCK_SUPPLY', 'LOCK_MINT', 'LOCK_DESCRIPTION', 'LOCK_RUG', 'LOCK_SLEEP', 'LOCK_CALLBACK') ); @@ -194,11 +196,11 @@ function btnsIssue( $params=null, $data=null, $error=null){ $error = 'invalid: MINT_SUPPLY > MAX_SUPPLY'; // Verify MINT_ADDRESS_MAX is less than MAX_SUPPLY - if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > $data->MAX_SUPPLY) + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > 0 && $data->MINT_ADDRESS_MAX > $data->MAX_SUPPLY) $error = 'invalid: MINT_ADDRESS_MAX > MAX_SUPPLY'; // Verify MINT_ADDRESS_MAX is greater than than MAX_MINT - if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX < $data->MAX_MINT) + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > 0 && $data->MINT_ADDRESS_MAX < $data->MAX_MINT) $error = 'invalid: MINT_ADDRESS_MAX < MAX_MINT'; // Verify MAX_SUPPLY can not be changed if LOCK_SUPPLY is enabled @@ -253,6 +255,18 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && isset($data->BLOCK_LIST) && !isValidList($data->BLOCK_LIST,3)) $error = 'invalid: BLOCK_LIST (bad list)'; + // Verify MINT_START_BLOCK is greater than or equal to current block + if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK < $data->BLOCK_INDEX) + $error = 'invalid: MINT_START_BLOCK < BLOCK_INDEX'; + + // Verify MINT_STOP_BLOCK is greater than or equal to current block + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_START_BLOCK < $data->BLOCK_INDEX) + $error = 'invalid: MINT_STOP_BLOCK < BLOCK_INDEX'; + + // Verify MINT_STOP_BLOCK is greater than or equal to MINT_START_BLOCK + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK < $data->MINT_START_BLOCK) + $error = 'invalid: MINT_STOP_BLOCK > MINT_START_BLOCK'; + // Determine final status $data->STATUS = $status = ($error) ? $error : 'valid'; diff --git a/indexer/includes/actions/mint.php b/indexer/includes/actions/mint.php index 1995c70..33ffd1c 100644 --- a/indexer/includes/actions/mint.php +++ b/indexer/includes/actions/mint.php @@ -56,6 +56,8 @@ function btnsMint($params=null, $data=null, $error=null){ $data->MAX_SUPPLY = ($btInfo) ? $btInfo->MAX_SUPPLY : 0; $data->MAX_MINT = ($btInfo) ? $btInfo->MAX_MINT : 0; $data->MINT_ADDRESS_MAX = ($btInfo) ? $btInfo->MINT_ADDRESS_MAX : 0; + $data->MINT_START_BLOCK = ($btInfo) ? $btInfo->MINT_START_BLOCK : 0; + $data->MINT_STOP_BLOCK = ($btInfo) ? $btInfo->MINT_STOP_BLOCK : 0; } /***************************************************************** @@ -90,10 +92,18 @@ function btnsMint($params=null, $data=null, $error=null){ if(!$error && isset($data->DESTINATION) && !isActionAllowed($data->TICK, $data->DESTINATION)) $error = 'invalid: DESTINATION (not authorized)'; - // Verify minting AMOUNT will not exceed MINT_ADDRESS_MAX + // Verify minting AMOUNT will not exceed MINT_ADDRESS_MAX if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX && (bcadd(getActionCreditDebitAmount('credits', 'MINT', $data->TICK, $data->SOURCE),$data->AMOUNT,$data->DECIMALS) > $data->MINT_ADDRESS_MAX)) $error = 'invalid: mint exceeds MINT_ADDRESS_MAX'; + // Verify minting begins at MINT_START_BLOCK + if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK && $data->BLOCK_INDEX < $data->MINT_START_BLOCK) + $error = 'invalid: MINT_START_BLOCK'; + + // Verify minting ends at MINT_STOP_BLOCK + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK && $data->BLOCK_INDEX > $data->MINT_STOP_BLOCK) + $error = 'invalid: MINT_STOP_BLOCK'; + // Determine final status $data->STATUS = $status = ($error) ? $error : 'valid'; diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index 987b6db..6d2b135 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -220,6 +220,8 @@ function createIssue( $data=null ){ $max_mint = (isset($data->MAX_MINT) && is_numeric($data->MAX_MINT)) ? $data->MAX_MINT : 0; $mint_supply = (isset($data->MINT_SUPPLY) && is_numeric($data->MINT_SUPPLY)) ? $data->MINT_SUPPLY : 0; $mint_address_max = (isset($data->MINT_ADDRESS_MAX) && is_numeric($data->MINT_ADDRESS_MAX)) ? $data->MINT_ADDRESS_MAX : 0; + $mint_start_block = (isset($data->MINT_START_BLOCK) && is_numeric($data->MINT_START_BLOCK)) ? $data->MINT_START_BLOCK : 0; + $mint_stop_block = (isset($data->MINT_STOP_BLOCK) && is_numeric($data->MINT_STOP_BLOCK)) ? $data->MINT_STOP_BLOCK : 0; $callback_amount = (isset($data->CALLBACK_AMOUNT) && is_numeric($data->CALLBACK_AMOUNT)) ? $data->CALLBACK_AMOUNT : 0; $decimals = (isset($data->DECIMALS)) ? $data->DECIMALS : 0; // Truncate description to 250 chars @@ -236,6 +238,8 @@ function createIssue( $data=null ){ $max_mint = $mysqli->real_escape_string($max_mint); $mint_supply = $mysqli->real_escape_string($mint_supply); $mint_address_max = $mysqli->real_escape_string($mint_address_max); + $mint_start_block = $mysqli->real_escape_string($mint_start_block); + $mint_stop_block = $mysqli->real_escape_string($mint_stop_block); $decimals = $mysqli->real_escape_string($decimals); $description = $mysqli->real_escape_string($description); $block_index = $mysqli->real_escape_string($data->BLOCK_INDEX); @@ -289,6 +293,8 @@ function createIssue( $data=null ){ allow_list_id='{$allow_list_id}', block_list_id='{$block_list_id}', mint_address_max='{$mint_address_max}', + mint_start_block='{$mint_start_block}', + mint_stop_block='{$mint_stop_block}', source_id='{$source_id}', block_index='{$block_index}', tx_index='{$tx_index}', @@ -297,7 +303,7 @@ function createIssue( $data=null ){ tx_hash_id='{$tx_hash_id}'"; } else { // INSERT record - $sql = "INSERT INTO issues (tick_id, max_supply, max_mint, decimals, description, mint_supply, transfer_id, transfer_supply_id, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, source_id, tx_hash_id, block_index, tx_index, status_id) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$mint_supply}', '{$transfer_id}', '{$transfer_supply_id}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$source_id}', '{$tx_hash_id}', '{$block_index}', '{$tx_index}', '{$status_id}')"; + $sql = "INSERT INTO issues (tick_id, max_supply, max_mint, decimals, description, mint_supply, transfer_id, transfer_supply_id, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, mint_start_block, mint_stop_block, source_id, tx_hash_id, block_index, tx_index, status_id) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$mint_supply}', '{$transfer_id}', '{$transfer_supply_id}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$mint_start_block}', '{$mint_stop_block}', '{$source_id}', '{$tx_hash_id}', '{$block_index}', '{$tx_index}', '{$status_id}')"; } // print $sql; $results = $mysqli->query($sql); @@ -462,6 +468,8 @@ function createToken( $data=null ){ $max_mint = (isset($data->MAX_MINT) && is_numeric($data->MAX_MINT)) ? $data->MAX_MINT : 0; $mint_supply = (isset($data->MINT_SUPPLY) && is_numeric($data->MINT_SUPPLY)) ? $data->MINT_SUPPLY : 0; $mint_address_max = (isset($data->MINT_ADDRESS_MAX) && is_numeric($data->MINT_ADDRESS_MAX)) ? $data->MINT_ADDRESS_MAX : 0; + $mint_start_block = (isset($data->MINT_START_BLOCK) && is_numeric($data->MINT_START_BLOCK)) ? $data->MINT_START_BLOCK : 0; + $mint_stop_block = (isset($data->MINT_STOP_BLOCK) && is_numeric($data->MINT_STOP_BLOCK)) ? $data->MINT_STOP_BLOCK : 0; $callback_amount = (isset($data->CALLBACK_AMOUNT) && is_numeric($data->CALLBACK_AMOUNT)) ? $data->CALLBACK_AMOUNT : 0; $decimals = (isset($data->DECIMALS)) ? $data->DECIMALS : 0; // Force any amount values to the correct decimal precision @@ -476,6 +484,8 @@ function createToken( $data=null ){ $max_supply = $mysqli->real_escape_string($max_supply); $max_mint = $mysqli->real_escape_string($max_mint); $mint_address_max = $mysqli->real_escape_string($mint_address_max); + $mint_start_block = $mysqli->real_escape_string($mint_start_block); + $mint_stop_block = $mysqli->real_escape_string($mint_stop_block); $decimals = $mysqli->real_escape_string($decimals); $description = $mysqli->real_escape_string($data->DESCRIPTION); $block_index = $mysqli->real_escape_string($data->BLOCK_INDEX); @@ -518,6 +528,8 @@ function createToken( $data=null ){ allow_list_id='{$allow_list_id}', block_list_id='{$block_list_id}', mint_address_max='{$mint_address_max}', + mint_start_block='{$mint_start_block}', + mint_stop_block='{$mint_stop_block}', block_index='{$block_index}', supply='{$supply}', owner_id='{$owner_id}' @@ -525,7 +537,7 @@ function createToken( $data=null ){ tick_id='{$tick_id}'"; } else { // INSERT record - $sql = "INSERT INTO tokens (tick_id, max_supply, max_mint, decimals, description, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, owner_id, supply, block_index) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$owner_id}','{$supply}', '{$block_index}')"; + $sql = "INSERT INTO tokens (tick_id, max_supply, max_mint, decimals, description, lock_supply, lock_mint, lock_description, lock_rug, lock_sleep, lock_callback, callback_block, callback_tick_id, callback_amount, allow_list_id, block_list_id, mint_address_max, mint_start_block, mint_stop_block, owner_id, supply, block_index) values ('{$tick_id}', '{$max_supply}', '{$max_mint}', '{$decimals}', '{$description}', '{$lock_supply}', '{$lock_mint}', '{$lock_description}', '{$lock_rug}', '{$lock_sleep}', '{$lock_callback}', '{$callback_block}', '{$callback_tick_id}', '{$callback_amount}', '{$allow_list_id}', '{$block_list_id}', '{$mint_address_max}', '{$mint_start_block}', '{$mint_stop_block}', '{$owner_id}','{$supply}', '{$block_index}')"; } // print $sql; $results = $mysqli->query($sql); @@ -929,6 +941,8 @@ function getTokenInfo($tick=null, $tick_id=null){ t4.hash as allow_list, t5.hash as block_list, t1.mint_address_max, + t1.mint_start_block, + t1.mint_stop_block, a.address as owner FROM tokens t1 @@ -966,7 +980,9 @@ function getTokenInfo($tick=null, $tick_id=null){ 'CALLBACK_AMOUNT' => $row->callback_amount, 'ALLOW_LIST' => $row->allow_list, 'BLOCK_LIST' => $row->block_list, - 'MINT_ADDRESS_MAX' => $row->mint_address_max + 'MINT_ADDRESS_MAX' => $row->mint_address_max, + 'MINT_START_BLOCK' => $row->mint_start_block, + 'MINT_STOP_BLOCK' => $row->mint_stop_block ); } } else { diff --git a/indexer/sql/issues.sql b/indexer/sql/issues.sql index 84ac91b..742005c 100644 --- a/indexer/sql/issues.sql +++ b/indexer/sql/issues.sql @@ -21,6 +21,8 @@ CREATE TABLE issues ( allow_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table block_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table mint_address_max VARCHAR(250), -- Maximum amount of supply an address can MINT + mint_start_block INTEGER UNSIGNED, -- block_index when MINT transactions are allowed (begin mint) + mint_stop_block INTEGER UNSIGNED, -- BLOCK_INDEX when MINT transactions are NOT allowed (end mint) source_id INTEGER UNSIGNED, -- id of record in index_addresses table (address that did DEPLOY) tx_hash_id INTEGER UNSIGNED, -- id of record in index_transactions block_index INTEGER UNSIGNED, -- block index of DEPLOY transaction diff --git a/indexer/sql/tokens.sql b/indexer/sql/tokens.sql index 1a5f8c8..74fd91e 100644 --- a/indexer/sql/tokens.sql +++ b/indexer/sql/tokens.sql @@ -20,6 +20,8 @@ CREATE TABLE tokens ( allow_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table block_list_id INTEGER UNSIGNED NOT NULL default 0, -- id of record in index_transactions table mint_address_max VARCHAR(250), -- Maximum amount of supply an address can MINT + mint_start_block INTEGER UNSIGNED, -- block_index when MINT transactions are allowed (begin mint) + mint_stop_block INTEGER UNSIGNED, -- BLOCK_INDEX when MINT transactions are NOT allowed (end mint) owner_id INTEGER UNSIGNED, -- id of record in index_addresses table btc_price VARCHAR(250) NOT NULL default 0 -- last price of BTC purchase of 1 token ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; @@ -34,4 +36,4 @@ CREATE INDEX lock_sleep ON tokens (lock_sleep); CREATE INDEX lock_callback ON tokens (lock_callback); CREATE INDEX callback_tick_id ON tokens (callback_tick_id); CREATE INDEX allow_list_id ON tokens (allow_list_id); -CREATE INDEX block_list_id ON tokens (block_list_id); \ No newline at end of file +CREATE INDEX block_list_id ON tokens (block_list_id); From e7316f4d217931a3bb9f241301981a340fb58beb Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 12 Feb 2024 08:35:58 -0800 Subject: [PATCH 05/16] revert `MINT_FEE` params removed `MINT_FEE` params https://github.com/jdogresorg/Broadcast-Token-Naming-System/discussions/29 --- docs/actions/ISSUE.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/docs/actions/ISSUE.md b/docs/actions/ISSUE.md index eb6996d..244722a 100644 --- a/docs/actions/ISSUE.md +++ b/docs/actions/ISSUE.md @@ -27,21 +27,18 @@ This command creates or issues a `BTNS` `token` | `MINT_ADDRESS_MAX` | String | Maximum amount of supply any address can mint via `MINT` transactions | | `MINT_START_BLOCK` | String | `BLOCK_INDEX` when `MINT` transactions are allowed (begin mint) | | `MINT_STOP_BLOCK` | String | `BLOCK_INDEX` when `MINT` transactions are NOT allowed (end mint) | -| `MINT_FEE_TICK` | String | `TICK` required in order to `MINT` | -| `MINT_FEE_AMOUNT` | String | `TICK` `AMOUNT` required in order to `MINT` | -| `MINT_FEE_ADDRESS` | String | Address where `MINT` fee can be sent instead of being destroyed | ## Formats ### Version `0` -- `VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK|MINT_FEE_TICK|MINT_FEE_AMOUNT|MINT_FEE_ADDRESS` +- `VERSION|TICK|MAX_SUPPLY|MAX_MINT|DECIMALS|DESCRIPTION|MINT_SUPPLY|TRANSFER|TRANSFER_SUPPLY|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK|CALLBACK_BLOCK|CALLBACK_TICK|CALLBACK_AMOUNT|ALLOW_LIST|BLOCK_LIST|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK` ### Version `1` - Edit `DESCRIPTION` - `VERSION|TICK|DESCRIPTION` ### Version `2` - Edit `MINT` `PARAMS` -- `VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK|MINT_FEE_TICK|MINT_FEE_AMOUNT|MINT_FEE_ADDRESS` +- `VERSION|TICK|MAX_MINT|MINT_SUPPLY|TRANSFER_SUPPLY|MINT_ADDRESS_MAX|MINT_START_BLOCK|MINT_STOP_BLOCK` ### Version `3` - Edit `LOCK` `PARAMS` - `VERSION|TICK|LOCK_SUPPLY|LOCK_MINT|LOCK_DESCRIPTION|LOCK_RUG|LOCK_SLEEP|LOCK_CALLBACK` @@ -130,7 +127,4 @@ This example issues a TEST token with a max supply of 100, and a maximum mint of - `counterparty` `ASSET` and `SUBASSET` names are reserved within the BTNS for use by the `counterparty` owner - `MINT_ADDRESS_MAX` can be used to limit the maximum `TICK` `AMOUNT` that a single address can `MINT` - `MINT_START_BLOCK` and `MINT_STOP_BLOCK` can be used to determine period(s) when `MINT` transactions are allowed -- `MINT_FEE_TICK` and `MINT_FEE_AMOUNT` can be used to require a set `TICK` `AMOUNT` fee be paid on a MINT transaction -- `MINT_FEE_ADDRESS` can be used to send `MINT` fees to an address instead of destroying the fee -- `MINT_FEE_TICK` can be set to `BTC` and `MINT_FEE_ADDRESS` set to `` to require a minimum BTC miners fee be paid on a MINT transactions From f836be2b2b36b71aebcac289dd560c8563a5a459 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 12 Feb 2024 11:04:47 -0800 Subject: [PATCH 06/16] BTNS GAS Utility Token spec --- docs/BTNS-GAS.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 docs/BTNS-GAS.md diff --git a/docs/BTNS-GAS.md b/docs/BTNS-GAS.md new file mode 100644 index 0000000..ddc765d --- /dev/null +++ b/docs/BTNS-GAS.md @@ -0,0 +1,57 @@ + Title: BTNS GAS Utility Token + Author: Jeremy Johnson (J-Dog) + Status: Draft + Type: Standards + Created: 2024-02-12 + +# Abstract +Establish an fairly minted GAS utility token + +# Motivation +Establish a standard GAS utility token to provide functionality where it isn't technically possible to use BTC. + +# Specification + +``` +GAS Supply : 10,000,000.00000000 (10M) +Mint Period : 30 days +Mint Method : Fair / Open Mint +``` + +### Mint Period 1 +``` +Mint Supply : 2,500,000.00000000 (2.5M) +Mint Amount : 60.0 GAS (40 GAS + 50% Bonus) +Mint Target : 41,666 transactions +Mint Starts : Block # XXX,XXXX +``` + +## Mint Period 2 +``` +Mint Supply : 2,500,000.00000000 (2.5M) +Mint Amount : 50.0 GAS (40 GAS + 25% Bonus) +Mint Target : 50,000 transactions +Mint Starts : Block # XXX,XXXX +``` + +## Mint Period 3 +``` +Mint Supply : 2,500,000.00000000 (2.5M) +Mint Amount : 44.0 GAS (40 GAS + 10% Bonus) +Mint Target : 56,818 transactions +Mint Starts : Block # XXX,XXXX +``` + +## Mint Period 4 +``` +Mint Supply : 2,500,000.00000000 (2.5M) +Mint Amount : 40.0 GAS (40 GAS + 0% Bonus) +Mint Target : 56,818 transactions +Mint Starts : Block # XXX,XXXX +``` + +# Notes +- Address `1BTNSGASK5En7rFurDJ79LQ8CVYo2ecLC8` is the initial issuing address for the GAS token +- Each period starts at a specific block # (1,008 blocks - 1 week) +- 2.5M GAS minted each period +- 1,000 GAS MINT per address limit in place \ No newline at end of file From 8927921382420ea5ca48ebb408c4a43c775fb3a4 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 12 Feb 2024 12:13:45 -0800 Subject: [PATCH 07/16] add MINT examples / cleanup --- docs/BTNS-GAS.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/BTNS-GAS.md b/docs/BTNS-GAS.md index ddc765d..c789785 100644 --- a/docs/BTNS-GAS.md +++ b/docs/BTNS-GAS.md @@ -18,7 +18,7 @@ Mint Period : 30 days Mint Method : Fair / Open Mint ``` -### Mint Period 1 +## Mint Period 1 ``` Mint Supply : 2,500,000.00000000 (2.5M) Mint Amount : 60.0 GAS (40 GAS + 50% Bonus) @@ -50,8 +50,15 @@ Mint Target : 56,818 transactions Mint Starts : Block # XXX,XXXX ``` +## Mint Examples +- Mint Period 1 = `bt:MINT|0|GAS|60` +- Mint Period 2 = `bt:MINT|0|GAS|50` +- Mint Period 3 = `bt:MINT|0|GAS|44` +- Mint Period 4 = `bt:MINT|0|GAS|40` + # Notes +- GAS can be minted via broadcasting a message via the `counterparty` `broadcast` function - Address `1BTNSGASK5En7rFurDJ79LQ8CVYo2ecLC8` is the initial issuing address for the GAS token -- Each period starts at a specific block # (1,008 blocks - 1 week) -- 2.5M GAS minted each period -- 1,000 GAS MINT per address limit in place \ No newline at end of file +- 2,500,000.00000000 (2.5M) GAS minted each period +- 1,000 GAS MINT per address limit in place +- Each period starts at a specific block # (1,008 blocks - 1 week) \ No newline at end of file From 6143b2b6e9e24a93214efaf8a74679b3f74664d7 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 12 Feb 2024 12:17:04 -0800 Subject: [PATCH 08/16] update testnet `GAS_ADDRESS` --- indexer/includes/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indexer/includes/config.php b/indexer/includes/config.php index 95e85a6..3aa3db2 100644 --- a/indexer/includes/config.php +++ b/indexer/includes/config.php @@ -49,7 +49,7 @@ // BTNS Address define('BURN_ADDRESS', "mvCounterpartyXXXXXXXXXXXXXXW24Hef"); - define('GAS_ADDRESS', "mvCounterpartyXXXXXXXXXXXXXXW24Hef"); + define('GAS_ADDRESS', "mvThcDEbeqog2aJ7JNj1FefUPaNdYYGqHt"); } // Database Credentials From 4265ad81d79be58f419e3c6a1675cd24a0714d01 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 12 Feb 2024 12:17:37 -0800 Subject: [PATCH 09/16] fix mint target for period 4 --- docs/BTNS-GAS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/BTNS-GAS.md b/docs/BTNS-GAS.md index c789785..6e46ea4 100644 --- a/docs/BTNS-GAS.md +++ b/docs/BTNS-GAS.md @@ -46,7 +46,7 @@ Mint Starts : Block # XXX,XXXX ``` Mint Supply : 2,500,000.00000000 (2.5M) Mint Amount : 40.0 GAS (40 GAS + 0% Bonus) -Mint Target : 56,818 transactions +Mint Target : 62,500 transactions Mint Starts : Block # XXX,XXXX ``` From 89792a4bc2836d488eb8a34f60529e2c94992634 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 12 Feb 2024 12:27:52 -0800 Subject: [PATCH 10/16] set GAS mint period start blocks ``` 830,200 = Current Block + 1,008 = 1 Week (7 days) --- 831,208 = Period 1 + 1,008 = 1 Week (7 days) --- 832,216 = Period 2 + 1,008 = 1 Week (7 days) --- 833,224 = Period 3 + 1,008 = 1 Week (7 days) --- 834,232 = Period 4 ``` --- docs/BTNS-GAS.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/BTNS-GAS.md b/docs/BTNS-GAS.md index 6e46ea4..8e718cb 100644 --- a/docs/BTNS-GAS.md +++ b/docs/BTNS-GAS.md @@ -13,9 +13,10 @@ Establish a standard GAS utility token to provide functionality where it isn't t # Specification ``` -GAS Supply : 10,000,000.00000000 (10M) -Mint Period : 30 days -Mint Method : Fair / Open Mint +Token Name : GAS +Total Supply : 10,000,000.00000000 (10M) +Mint Period : 30 days +Mint Method : Fair / Open Mint ``` ## Mint Period 1 @@ -23,7 +24,7 @@ Mint Method : Fair / Open Mint Mint Supply : 2,500,000.00000000 (2.5M) Mint Amount : 60.0 GAS (40 GAS + 50% Bonus) Mint Target : 41,666 transactions -Mint Starts : Block # XXX,XXXX +Mint Starts : Block # 831,208 ``` ## Mint Period 2 @@ -31,7 +32,7 @@ Mint Starts : Block # XXX,XXXX Mint Supply : 2,500,000.00000000 (2.5M) Mint Amount : 50.0 GAS (40 GAS + 25% Bonus) Mint Target : 50,000 transactions -Mint Starts : Block # XXX,XXXX +Mint Starts : Block # 832,216 ``` ## Mint Period 3 @@ -39,7 +40,7 @@ Mint Starts : Block # XXX,XXXX Mint Supply : 2,500,000.00000000 (2.5M) Mint Amount : 44.0 GAS (40 GAS + 10% Bonus) Mint Target : 56,818 transactions -Mint Starts : Block # XXX,XXXX +Mint Starts : Block # 833,224 ``` ## Mint Period 4 @@ -47,7 +48,7 @@ Mint Starts : Block # XXX,XXXX Mint Supply : 2,500,000.00000000 (2.5M) Mint Amount : 40.0 GAS (40 GAS + 0% Bonus) Mint Target : 62,500 transactions -Mint Starts : Block # XXX,XXXX +Mint Starts : Block # 834,232 ``` ## Mint Examples From 1616cd8ebc28c511d5c052d701a24dd5a468be18 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Tue, 13 Feb 2024 13:12:22 -0800 Subject: [PATCH 11/16] cleanup --- indexer/includes/actions/issue.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index 49fd991..9ea13cf 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -90,13 +90,9 @@ function btnsIssue( $params=null, $data=null, $error=null){ $error = 'invalid: TICK (semicolon)'; // Verify TICK is not on RESERVED_TICKS list - if(!$error && in_array($data->TICK,RESERVED_TICKS)) + if(!$error && in_array($data->TICK,RESERVED_TICKS)) $error = 'invalid: TICK (reserved)'; - // Verify TRANSFER_SUPPLY and SOURCE are different - if($data->TRANSFER_SUPPLY == $data->SOURCE) - unset($data->TRANSFER_SUPPLY); - // Get information on BTNS token $btInfo = getTokenInfo($data->TICK); $isDistributed = isDistributed($data->TICK); @@ -187,6 +183,10 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && isset($data->TRANSFER) && !isCryptoAddress($data->TRANSFER)) $error = 'invalid: TRANSFER (bad address)'; + // Verify TRANSFER_SUPPLY and SOURCE are different + if($data->TRANSFER_SUPPLY == $data->SOURCE) + unset($data->TRANSFER_SUPPLY); + // Verify TRANSFER_SUPPLY addresses if(!$error && isset($data->TRANSFER_SUPPLY) && !isCryptoAddress($data->TRANSFER_SUPPLY)) $error = 'invalid: TRANSFER_SUPPLY (bad address)'; From f1be294bb0797c4dcc0820576c16548789ffc4a9 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Tue, 13 Feb 2024 21:47:38 -0800 Subject: [PATCH 12/16] cleanup `MINT_*` validations --- indexer/includes/actions/issue.php | 8 ++++---- indexer/includes/actions/mint.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index 9ea13cf..2ba422b 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -256,16 +256,16 @@ function btnsIssue( $params=null, $data=null, $error=null){ $error = 'invalid: BLOCK_LIST (bad list)'; // Verify MINT_START_BLOCK is greater than or equal to current block - if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK < $data->BLOCK_INDEX) + if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->MINT_START_BLOCK < $data->BLOCK_INDEX) $error = 'invalid: MINT_START_BLOCK < BLOCK_INDEX'; // Verify MINT_STOP_BLOCK is greater than or equal to current block - if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_START_BLOCK < $data->BLOCK_INDEX) + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK > 0 && $data->MINT_STOP_BLOCK < $data->BLOCK_INDEX) $error = 'invalid: MINT_STOP_BLOCK < BLOCK_INDEX'; // Verify MINT_STOP_BLOCK is greater than or equal to MINT_START_BLOCK - if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK < $data->MINT_START_BLOCK) - $error = 'invalid: MINT_STOP_BLOCK > MINT_START_BLOCK'; + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->MINT_STOP_BLOCK > 0 && $data->MINT_STOP_BLOCK < $data->MINT_START_BLOCK) + $error = 'invalid: MINT_STOP_BLOCK < MINT_START_BLOCK'; // Determine final status $data->STATUS = $status = ($error) ? $error : 'valid'; diff --git a/indexer/includes/actions/mint.php b/indexer/includes/actions/mint.php index 33ffd1c..746fe1f 100644 --- a/indexer/includes/actions/mint.php +++ b/indexer/includes/actions/mint.php @@ -93,15 +93,15 @@ function btnsMint($params=null, $data=null, $error=null){ $error = 'invalid: DESTINATION (not authorized)'; // Verify minting AMOUNT will not exceed MINT_ADDRESS_MAX - if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX && (bcadd(getActionCreditDebitAmount('credits', 'MINT', $data->TICK, $data->SOURCE),$data->AMOUNT,$data->DECIMALS) > $data->MINT_ADDRESS_MAX)) + if(!$error && isset($data->MINT_ADDRESS_MAX) && $data->MINT_ADDRESS_MAX > 0 && (bcadd(getActionCreditDebitAmount('credits', 'MINT', $data->TICK, $data->SOURCE),$data->AMOUNT,$data->DECIMALS) > $data->MINT_ADDRESS_MAX)) $error = 'invalid: mint exceeds MINT_ADDRESS_MAX'; // Verify minting begins at MINT_START_BLOCK - if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK && $data->BLOCK_INDEX < $data->MINT_START_BLOCK) + if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->BLOCK_INDEX < $data->MINT_START_BLOCK) $error = 'invalid: MINT_START_BLOCK'; // Verify minting ends at MINT_STOP_BLOCK - if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK && $data->BLOCK_INDEX > $data->MINT_STOP_BLOCK) + if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK > 0 && $data->BLOCK_INDEX > $data->MINT_STOP_BLOCK) $error = 'invalid: MINT_STOP_BLOCK'; // Determine final status From b8eac1a98df21ae0140a2e5bcb905a4562f4686b Mon Sep 17 00:00:00 2001 From: J-Dog Date: Tue, 13 Feb 2024 21:50:19 -0800 Subject: [PATCH 13/16] GAS updates --- indexer/includes/actions/issue.php | 4 ++++ indexer/includes/config.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index 2ba422b..ed062aa 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -93,6 +93,10 @@ function btnsIssue( $params=null, $data=null, $error=null){ if(!$error && in_array($data->TICK,RESERVED_TICKS)) $error = 'invalid: TICK (reserved)'; + // Verify only GAS_ADDRESS can issue GAS token + if(!$error && strtoupper($data->TICK)=='GAS' && $data->SOURCE!=GAS_ADDRESS) + $error = 'invalid: GAS_ADDRESS'; + // Get information on BTNS token $btInfo = getTokenInfo($data->TICK); $isDistributed = isDistributed($data->TICK); diff --git a/indexer/includes/config.php b/indexer/includes/config.php index 3aa3db2..879eeb5 100644 --- a/indexer/includes/config.php +++ b/indexer/includes/config.php @@ -18,7 +18,7 @@ define("MAX_TICK_LENGTH",250); // Reserved BTNS TICK names -$reserved = array('BTC','XCP','GAS'); +$reserved = array('BTC','XCP'); define("RESERVED_TICKS",$reserved); // Min/Max MAX_SUPPLY From e406e29599f13d87b6d04a6335b1f4ef34c23926 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Tue, 13 Feb 2024 22:43:01 -0800 Subject: [PATCH 14/16] refine AIRDROP spec - added `MEMO` param - added support for multiple airdrops, memos, and lists --- docs/actions/AIRDROP.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/actions/AIRDROP.md b/docs/actions/AIRDROP.md index 02decab..257ccd5 100644 --- a/docs/actions/AIRDROP.md +++ b/docs/actions/AIRDROP.md @@ -8,14 +8,22 @@ This command airdrops `token` supply to one or more `BTNS` lists. | `TICK` | String | 1 to 250 characters in length | | `AMOUNT` | String | Amount of `tokens` to airdrops | | `LIST` | String | `TX_HASH` of a BTNS `LIST` commands | +| `MEMO` | String | An optional memo to include | ## Formats ### Version `0` -- `VERSION|TICK|AMOUNT|LIST|LIST` +- `VERSION|TICK|AMOUNT|LIST|MEMO` + +### Version `1` - Single List, Multiple airdrops, Single memo +- `VERSION|LIST|TICK|AMOUNT|TICK|AMOUNT|MEMO` + +### Version `2` - Multiple Lists, Multiple airdrops, Single memo +- `VERSION|TICK|AMOUNT|LIST|TICK|AMOUNT|LIST|MEMO` + +### Version `3` - Multiple Lists, Multiple Airdrops, Multiple memos +- `VERSION|TICK|AMOUNT|LIST|MEMO|TICK|AMOUNT|LIST|MEMO` -### Version `1` -- `VERSION|TICK|AMOUNT|LIST|TICK|AMOUNT|LIST` ## Examples ``` @@ -31,8 +39,12 @@ This example airdops 1 GAS to every holder on a list and 2 BRRR to every holder ## Rules ## Notes -- Use format `0` to send the same `AMOUNT` of `token` to one or more `LIST` -- Use format `1` to send multiple `AMOUNT` of multiple `token` to different `LIST` - `AIRDROP` to `address` `LIST` sends `AMOUNT` of `token` to each address on the list - `AIRDROP` to `token` `LIST` sends `AMOUNT` of `token` to holders of each `token` on the list - `AIRDROP` to `ASSET` `LIST` sends `AMOUNT` of `token` to holders of each `ASSET` on the list +- Format version `0` allows for a single airdrop +- Format version `1` allows for repeating `TICK` and `AMOUNT` params to enable multiple airdrops to a single list +- Format version `2` allows for repeating `TICK`, `AMOUNT` and `LIST` params to enable multiple airdrops to multiple lists +- Format version `3` allows for repeating `TICK`, `AMOUNT`, `LIST`, and `MEMO` params to enable multiple airdrops to multiple lists with multiple memos +- Format version `0`, `1`, and `2` allow for a single optional `MEMO` field to be included as the last PARAM + From 330ad3aee0627864e7aea65c4c03581c5bbdc003 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Tue, 13 Feb 2024 22:58:01 -0800 Subject: [PATCH 15/16] cleanup --- docs/actions/AIRDROP.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/actions/AIRDROP.md b/docs/actions/AIRDROP.md index 257ccd5..068bdef 100644 --- a/docs/actions/AIRDROP.md +++ b/docs/actions/AIRDROP.md @@ -2,26 +2,26 @@ This command airdrops `token` supply to one or more `BTNS` lists. ## PARAMS -| Name | Type | Description | -| --------- | ------ | ----------------------------------- | -| `VERSION` | String | Broadcast Format Version | -| `TICK` | String | 1 to 250 characters in length | -| `AMOUNT` | String | Amount of `tokens` to airdrops | -| `LIST` | String | `TX_HASH` of a BTNS `LIST` commands | -| `MEMO` | String | An optional memo to include | +| Name | Type | Description | +| --------- | ------ | ------------------------------| +| `VERSION` | String | Broadcast Format Version | +| `TICK` | String | 1 to 250 characters in length | +| `AMOUNT` | String | Amount of `tokens` to airdrop | +| `LIST` | String | `TX_HASH` of a BTNS `LIST` | +| `MEMO` | String | An optional memo to include | ## Formats -### Version `0` +### Version `0` - Single Airdrop - `VERSION|TICK|AMOUNT|LIST|MEMO` -### Version `1` - Single List, Multiple airdrops, Single memo +### Version `1` - Multi-Airdrop (brief) - `VERSION|LIST|TICK|AMOUNT|TICK|AMOUNT|MEMO` -### Version `2` - Multiple Lists, Multiple airdrops, Single memo +### Version `2` - Multi-Airdrop (Full) - `VERSION|TICK|AMOUNT|LIST|TICK|AMOUNT|LIST|MEMO` -### Version `3` - Multiple Lists, Multiple Airdrops, Multiple memos +### Version `3` - Multi-Airdrop (Full) with Multiple Memos - `VERSION|TICK|AMOUNT|LIST|MEMO|TICK|AMOUNT|LIST|MEMO` From 16e07315bcd8da9e042038526b92fc60f1226572 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Wed, 14 Feb 2024 08:57:55 -0800 Subject: [PATCH 16/16] version bump to 0.11.1 --- indexer/CHANGELOG.md | 6 ++++++ indexer/includes/config.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/indexer/CHANGELOG.md b/indexer/CHANGELOG.md index 991b0d7..bcf6990 100644 --- a/indexer/CHANGELOG.md +++ b/indexer/CHANGELOG.md @@ -1,5 +1,11 @@ CHANGELOG --- +0.11.1 +- Added support for `MINT_START_BLOCK` +- Added support for `MINT_STOP_BLOCK` +- Added support for `MINT_ADDRESS_MAX` +- Updates to support `GAS` minting + 0.11.0 - DESTROY support - Added basic sanity checks diff --git a/indexer/includes/config.php b/indexer/includes/config.php index 879eeb5..0ed44e7 100644 --- a/indexer/includes/config.php +++ b/indexer/includes/config.php @@ -10,7 +10,7 @@ // BTNS Indexer Version define("VERSION_MAJOR", 0); define("VERSION_MINOR", 11); -define("VERSION_REVISION",0); +define("VERSION_REVISION",1); define("VERSION_STRING", VERSION_MAJOR . '.' . VERSION_MINOR . '.' . VERSION_REVISION); // TICK constants