Package: fat
fat-pyPython library for theFactom Asset Tokenstandard. Currently supports FAT-0 and FAT-1 token standards.InstallationThe easiest way to install is withpiporpipenvfrom PyPi:pipenv install fatYou can also clone the repo and build it from source. The recommended way to do this is withpipenv:git clone git@github.com:samuelvanderwaal/fat-py.gitcd fat-pyInstall requirements from the Pipfile:pipenv installActivate the virtual environment:pipenv shellSeepipenv'sdocumentationfor more usage details.Quick StartIssue a new token:fromfat.fat0importIssuancefromfactomimportFactomdfactomd=Factomd()issuance=Issuance(token_id="mytoken",issuer_id="8888...",supply=-1,symbol="tkn1",ec_address="EC3...",ec_priv_key="ES3...",server_priv_key="sk1...")issuance.issue_token(factomd)Build and submit a token transaction:fromfat.fat0importTransactionfromfatimportFATdfatd=FATd()address1="FA2gCmih3PaSYRVMt1jLkdG4Xpo2koebUpQ6FpRRnqw5FfTSN2vW"private_fct_key1="Fs..."address2="FA3j68XNwKwvHXV2TKndxPpyCK3KrWTDyyfxzi8LwuM5XRuEmhy6"chain_id="a9d7791caffd852f8e3710e3c38f1ad1b056d4ecb2d4d54216581dfd0dac8edd"tx1=Transaction()tx1.add_input(address1,100)tx1.add_output(address2,100)tx1.add_signer(private_fct_key1)tx1.set_chain_id(chain_id)tx1.sign()fatd.submit_transaction(tx1)UsageThe two main ways to use this library are the Issuance and Transaction classes. In addition, the library exposes all the fatd RPC methods which can be accessed through the FATd class.IssuanceThe Issuance class supports object initialization through multiple methods:Individual property assignment:issuance=Issuance()issuance.token_id="mytoken"issuance.issuer_id="888888a37cbf303c0bfc8d0cc7e77885c42000b757bd4d9e659de994477a0904"issuance.supply=-1issuance.symbol="tkn1"issuance.ec_address="EC3cQ1QnsE5rKWR1B5mzVHdTkAReK5kJwaQn5meXzU9wANyk7Aej"issuance.ec_priv_key="ES..."issuance.server_priv_key="sk1..."Passing all values as part of the constructor:issuance=Issuance(token_id="mytoken",issuer_id="8888...",supply=-1,symbol="tkn1",ec_address="EC3...",ec_priv_key="ES3...",server_priv_key="sk1...")Once the issuance object has all the required values, theissue_token()method can be used to perform all the necessaryfactomdcalls to issue and initialize a new token.fromfat.fat0importIssuancefromfactomimportFactomdfactomd=Factomd()issuance=Issuance(token_id="mytoken",issuer_id="8888...",supply=-1,symbol="tkn1",ec_address="EC3...",ec_priv_key="ES3...",server_priv_key="sk1...")issuance.issue_token(factomd)Issuance supports both the Python nativestrtype and key objects from thefactom_keyslibrary for EC and server ID keys. When strings are passed to it, internally it uses thefactom_keyslibrary to validate the key and address values....fromfactom_keys.ecimportECAddressec_address1=ECAddress(key_string="EC3cQ1QnsE5rKWR1B5mzVHdTkAReK5kJwaQn5meXzU9wANyk7Aej")ec_address2="EC3cQ1QnsE5rKWR1B5mzVHdTkAReK5kJwaQn5meXzU9wANyk7Aej"issuance=Issuance()...issuance.ec_address=ec_address1# orissuance.ec_address=ec_address2FAT-0 and FAT-1 issuance has the same usage, just import the specific Issuance class needed. Use import aliases if both are required simultaneously:fromfat.fat0importIssuanceasFAT0Issuancefromfat.fat1importIssuanceasFAT1IssuanceTransactionThe Transaction class also supports multiple methods of initialization:Passing all values through the constructor:tx1=Transaction(inputs={"FA...":100,"FA3...":50},outputs={"FA3Z...":150},chain_id="a9d7791caffd852f8e3710e3c38f1ad1b056d4ecb2d4d54216581dfd0dac8edd",signers=["FS...","Fs..."])tx1.sign()Adding values individually:tx1=Transaction()tx1.add_input(coinbase_address,100)tx1.add_output(address1,50)tx1.add_output(address2,50)tx1.add_signer(issuer_signer)tx1.set_chain_id(chain_id)tx1.sign()Builder method:tx1=Transaction()(tx1.add_input(coinbase_address,100).add_output(address1,50).add_output(address2,50).add_signer(issuer_signer).set_chain_id(chain_id).sign())Transaction supports both the native Pythonstrtype and key objects from thefactom_keyslibrary for Factoid private keys, Factoid addresses and for server ID private keys....fromfactom_keys.ecimportFactoidAddress,FactoidPrivateKeyfromfactom_keys.serveridimportServerIDPrivateKeyaddress1=FactoidAddress(address_string="FA2gCmih3PaSYRVMt1jLkdG4Xpo2koebUpQ6FpRRnqw5FfTSN2vW")address2="FA2gCmih3PaSYRVMt1jLkdG4Xpo2koebUpQ6FpRRnqw5FfTSN2vW"fct_priv_key1=FactoidPrivateKey(key_string="Fs...")fct_priv_key2="Fs..."tx=Transaction()tx.add_input(address1,50)tx.add_signer(fct_priv_key1)# ortx.add_input(address2,50)tx.add_signer(fct_priv_key2)Once a transaction has been built and signed, it can be passed to thesubmit_transaction()method on FATd for submission to the blockchain.FAT-0:fromfat.fat0importTransactionfromfatimportFATdfatd=FATd()address1="FA2gCmih3PaSYRVMt1jLkdG4Xpo2koebUpQ6FpRRnqw5FfTSN2vW"private_fct_key1="Fs..."address2="FA3j68XNwKwvHXV2TKndxPpyCK3KrWTDyyfxzi8LwuM5XRuEmhy6"chain_id="a9d7791caffd852f8e3710e3c38f1ad1b056d4ecb2d4d54216581dfd0dac8edd"tx1=Transaction()tx1.add_input(address1,100)tx1.add_output(address2,100)tx1.add_signer(private_fct_key1)tx1.set_chain_id(chain_id)tx1.sign()fatd.submit_transaction(tx1)FAT-1:fromfat.fat1importTransactionfromfatimportFATdfatd=FATd()address1="FA2gCmih3PaSYRVMt1jLkdG4Xpo2koebUpQ6FpRRnqw5FfTSN2vW"private_fct_key1="Fs..."address2="FA3j68XNwKwvHXV2TKndxPpyCK3KrWTDyyfxzi8LwuM5XRuEmhy6"chain_id="a9d7791caffd852f8e3710e3c38f1ad1b056d4ecb2d4d54216581dfd0dac8edd"tx1=Transaction()tx1.add_input(address1,[1,3])tx1.add_output(address2,[1,3])tx1.add_signer(private_fct_key1)tx1.set_chain_id(chain_id)tx1.sign()fatd.submit_transaction(tx1)FATd RPC MethodsAll FATd RPC and Daemon methods are exposed via the FATd class:fromfatimportFATdfatd=FATd()chain_id="a9d7791caffd852f8e3710e3c38f1ad1b056d4ecb2d4d54216581dfd0dac8edd"address="FA2gCmih3PaSYRVMt1jLkdG4Xpo2koebUpQ6FpRRnqw5FfTSN2vW"fatd.get_issuance(chain_id=chain_id)fad.get_balance(address,chain_id=chain_id)fatd.get_daemon_properties()