Created
August 14, 2022 18:55
-
-
Save kalouo/5152546ce41a80ef2c297ef0a88709d4 to your computer and use it in GitHub Desktop.
Chinstrap FA2 origination with allocated tokens.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exampel of storage whereby fungible tokens are allocated at origination. | |
def deploy(chinstrapState, network, accounts): | |
contract = getContract("test_currency") | |
initial_storage = contract.storage.encode( | |
{ | |
"administrator": accounts[0].key.public_key_hash(), | |
"last_token_id": 1, | |
"ledger": { | |
# The value is exponentiated by the token decimal. | |
(accounts[1].key.public_key_hash(), 0): 1000*(10**18) | |
}, | |
"metadata": {'': '0x687474703a2f2f6578616d706c652e636f6d'}, | |
"operators": {}, | |
"supply": {0: 1000*(10**18)}, | |
"token_metadata": { | |
0: { | |
"token_id": 0, | |
"token_info": { | |
# The below values are the output of sp.utils.bytes_of_string | |
# or alternatively the make_metadata helper function in SmartPy's | |
# template contract. | |
'decimals': '0x3138', | |
'name': '0x4578616d706c6520464132', | |
'symbol': '0x454641322d32' | |
} | |
} | |
} | |
} | |
) | |
return initial_storage, contract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deploy(chinstrapState, network, accounts): | |
contract = getContract("test_nft") | |
initial_storage = contract.storage.encode( | |
{ | |
"administrator": accounts[0].key.public_key_hash(), | |
"last_token_id": 1, | |
"ledger": {0: accounts[2].key.public_key_hash()}, | |
"metadata": {'': '0x687474703a2f2f6578616d706c652e636f6d'}, | |
"operators": {}, | |
"token_metadata": { | |
0: { | |
"token_id": 0, | |
"token_info": { | |
'decimals': '0x30', | |
'name': '0x4578616d706c6520464132', | |
'symbol': '0x454641322d32' | |
} | |
} | |
} | |
}) | |
return initial_storage, contract |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment