Hello world! Welcome to another edition of the Web3 Python Weekly. Each week we’ll bring you one exercise, tweet, & video to keep you up to date on all things happening at the crossroads of Web3 & python. Thanks for joining us!
Automate Cross Chain Transactions Using Off-chain Data with William Chang
Why automate using PalomaPy?
First off, what is PalomaPy (Paloma-SDK)? More on Paloma's Python Client Library and Paloma Chain in our previous issue.
PalomaPy was built for the convenience of all Python developers out there. Builders are able to maximize their Python knowledge to build on top of Cosmos and communicate with EVM Chains.
Automation, especially cross chain, is an undervalued tool that we wish to bring to light.
What’s an example of what PalomaPy can do when it comes to interchain automation?
Using the paloma-sdk, we can build several cross chain automation features.
One would be to create a job using paloma-cli or paloma-sdk in Python. After that, we can build optimize an automation script to read the some offchain data and to execute the job with the same data using paloma-sdk when we need to trigger any transaction on an EVM chain.
So in short, we can build an automation feature to execute any transaction on EVM chain according to the offchain data using PalomaPy.
Usage Example:
from paloma_sdk.client.lcd import AsyncLCDClient
from paloma_sdk.key.mnemonic import MnemonicKey
async def example_create_execute_jobs():
paloma = AsyncLCDClient(url="https://lcd.testnet.palomaswap.com/", chain_id="paloma-testnet-15")
paloma.gas_prices = "0.01ugrain"
acc = MnemonicKey(
mnemonic="this is 24 mnemonic word"
)
test1 = paloma.wallet(acc)
job_id = "test-job"
contract_address = "0x1f576F2021b6EBdF229750f54fDFd31206141E65"
abi = [{"inputs":[],"name":"retrieve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"}]
payload = "6057361d0000000000000000000000000000000000000000000000000000000000000000" # default payload
chain_type = "evm"
chain_reference_id = "bnb-main"
result = await paloma.job_scheduler.create_job(
test1, job_id, contract_address, abi, payload, chain_type, chain_reference_id
)
payload = "6057361d0000000000000000000000000000000000000000000000000000000000000001" # payload to execute
result = await paloma.job_scheduler.execute_job(test1, job_id, payload)
await paloma.session.close()
How can developers get started?
1. Download the PalomaPy library from Pypi and install the packages
2. Check out our Quickstart Instructions
3. Join the Paloma Python channel on our Discord and come tell us how we can improve the Paloma Python SDK for you
For specific questions, you could open an issue or reach out to us on Discord.
You can find more information about us here:
Website
Docs
Github
AI x Python: Useful?
Contract Testing: Working Smarter
Python clean code tip:
Use contract testing when you want to verify the same behavior for different implementations
Useful when:
- You want to improve the current implementation and switch between old/new using a feature flag
- You want an in-memory test double
👇
That's it for today & see ya next time! If you liked this issue, be sure to share! 🐍