Package: chainlibpy
chainlibpyTools forCrypto.org Chainwallet management and offline transaction signingInstallingUsageGenerating a walletSigning and broadcasting a transactionInteract with mainnet or testnetAcknowledgementDevelopmentSet up development environmentAdd pre-commit git hookGenerate gRPC codeToxInstallingRequire Python >= 3.8, installing fromPyPI repository:pipinstallchainlibpyUsageGenerating a walletfromchainlibpyimportWallet# create a walletwallet=Wallet.new()# or you can recover from an mnomic# mnemonic = "dune car envelope chuckle elbow slight proud fury remove candy uphold puzzle call select sibling sport gadget please want vault glance verb damage gown"# wallet = Wallet(mnemonic)print(wallet.private_key)print(wallet.public_key)print(wallet.address)Signing and broadcasting a transactionPlease refer toexample/transaction.pyfor how to start a local testnet withpystarportand change information below to run the examples successfully.# Obtained from {directory_started_pystarport}/data/chainmaind/accounts.json
# To recover one of the genesis account- MNEMONIC_PHRASE = "first ... last"+ MNEMONIC_PHRASE = "REMEMBER TO CHANGE"# Obtained from {directory_started_pystarport}/data/chainmaind/accounts.json- TO_ADDRESS = "cro...add"+ TO_ADDRESS = "REMEMBER TO CHANGE"Interact with mainnet or testnetPlease refer toexample/secure_channel_example.pyon how to use secure gRPC channel with server certificate to interact with mainnet or testnet.AcknowledgementThanks tocosmospyfor the following:referenced the packages to sign transaction and create hd walletpython lint config fileuse same sign methodThanks toeth-utilsfor the following:Conversion of different units without facing precision issues in PythonDevelopmentSet up development environmentRun command below to install dependencies (more aboutpoetry):poetryinstallAdd pre-commit git hookTo set up the git hook scripts, so thatpre-commitwill run automatically ongit commit:pre-commitinstallGenerate gRPC codepoetryshell
./generated_protos.shNOTE:By default,masterbranch ofcosmos-sdkis used. Use command below to download a different version:./generated_protos.sh-COSMOS_REF=v0.44.5If more generated gRPC code is needed in the future, please add the path to.protofile needed here ingenerated_protos.sh:# Add .proto files here to generate respective gRPC code
PROTO_FILES="
$COSMOS_SDK_DIR/proto/cosmos/auth/v1beta1/auth.proto+$COSMOS_SDK_DIR/proto/other.proto...ToxToxis a tool to automate and standardize testing processes in Python.For this project, the list of environment that will be run when invokingtoxcommand ispy{38,39}. Hence we need to set up Python 3.8 and 3.9 for this project. Run command below to set a local application-specific Python version (in this case 3.8 and 3.9) withpyenv:pyenvlocal3.8.a3.9.bNote:aandbare python versions installed on your computer bypyenv.After running command above, a.python-versionfile will be generated, which means python versions inside.python-versionare presented for this project. Now, running commandtoxshould succeed without prompting environment missing error.Run command below to verify:poetryruntox# orpoetryshell
toxIt is also recommended to runtoxcommand before pushing a commit.