Overview
TRONscription introduces a novel approach to create trc-20 tokens and digital assets on the TRON network through transaction calldata or smart contract events. Here's a refined overview:
- Only successful transactions are considered, and processed by block number and transaction index sequence.
- TRONscription content (interpreted as UTF-8) must be a valid Data URL starting with
data:
. - TRONscription's identifier is the corresponding transaction hash, ensuring only one valid TRONscription per transaction.
- Each TRONscription is unique; if the sha256 hash of the Data URL content already exist, the subsequent one is disregarded.
Deploy trc-20
To deploy a trc-20 token from an EOA, certain rules must be followed due to TRON's restrictions on self-transfers of 0 TRX. The deployment process must adhere to the following guidelines:
- An EOA can only transfer TRX and must send a minimum of 0.000001 TRX.
- The recipient must be the black hole address
T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb
. - Calldata must be a valid Data URL containing specific fields as outlined below.
- The Data URL's content should not contain any white space, zero-width, or special characters.For example:
data:,{"p":"trxs/trc-20","op":"deploy","tick":"your_tick","max":"21000000","lim":"1000","dec":"6","mint":""}
Mint trc-20
You have the option to mint trc-20 tokens either from an EOA or through a smart contract. In both cases, the content of the Data URL must include the specified fields outlined below.
For example: data:,{"p":"trxs/trc-20","op":"mint","tick":"your_tick","amt":"1000","id":"1"}
From an EOA
If the mint
field is not specified for the deployed trc-20 token, you have the option to mint it from an EOA. Just like deploying a trc-20 token, you can transfer 0.000001 TRX to the black hole address with the calldata as described above to mint trc-20 tokens. Upon off-chain validation as a legitimate token mint:
- The creator and initial owner of the TRONscription is identified as the sender of the creation transaction.
- The transaction hash associated with the creation of the TRONscription serves as its unique identifier.
From a Smart Contract
If the mint
field is specified for the deployed trc-20 token, only tokens issued by the designated mint
smart contract are considered valid. The mint contract can generate an event, as outlined below, to signify a minting action.
As there could be multiple CreateTrxscription
events within a single transaction, it is crucial to maintain a one-to-one relationship between TRONscriptions and transactions. To ensure this alignment, the following guidelines must be adhered to:
- When minting tokens through a
mint
contract, any EOA calldata is disregarded, even if it conforms to a valid Data URL. -
CreateTrxscription
events should be sequentially processed based on log indices. Once a valid token mint is identified, subsequent events will be disregarded.
Upon off-chain validation of the CreateTrxscription
event as a legitimate token mint:
- Set
initialOwner
as the initial owner of the minted token. - Designate the emitting smart contract as it's creator.
Transfer trc-20
Similar to deploying trc-20 tokens, transferring multiple TRONscriptions to a recipient from an EOA involves providing calldata containing a sequence of valid TRONscription ids. These transfers are processed based on block number and transaction indices, following these guidelines:
- Exclude the leading
0x
in the calldata for multiple TRONscription ids. For instance, calldata to transfer two TRONscriptions may appear as:4e44c42e83e941e76af3db478ee4aba86a7fad08ead3a4d8a0beeabe7c40b1b436fb208e1611a7fc916d58860d6ea2494eff67a59292edd37cfa7f2cf8b81663
. - Validate the calldata for transfers by ensuring its length is a multiple of 64 characters and contains only hexadecimal characters (0-9a-fA-F).
- Process transfers sequentially based on TRONscription ids. If any transfer is invalid, skip it and proceed to the next.
- Transfer a TRONscription to the recipient only if the transaction sender is the current owner of the TRONscription.
Upon transferring one TRONscription from the sender to the recipient:
- Designate sender (
from
) as the previous owner of the TRONscription. - Assign recipient (
to
) as the current owner of the TRONscription.
From a Smart Contract
The TransferTrxscriptionForPreviousOwner
event facilitates smart contracts to safely and trustlessly escrow TRONscriptions, more commonly utilized in marketplaces. It accomplishes this by offering a mechanism of conditional transfers: transfer the TRONscription to the recipient only if previousOwner escrowed it.
When a contract emits the TransferTrxscriptionForPreviousOwner
event, execute the transfer of the TRONscription with id
from the emitting contract to recipient
under the following conditions:
- The emitting contract is the current owner of the TRONscription.
- The TRONscription's previous owner is identified as
previousOwner
.