If you haven't seen my previous tweet where i dive into Web3 py, check it out here:
Or this one, where i explain how to install the package and set up a connection
In this explanation im going to dive into executing the transaction itself. Define the variables, such as the ABI, wallet from, wallet to and smart contract address (again check the last tweet where to get this info). I deployed my smart contract via @thirdweb_
@thirdweb_ The first line tells python how to communicate with Polygon, which operates at a different layer. It's a bit tricky, but read the docs if you want more info.
Nonces act as counters that keeps track of the number of transactions sent by an account. We're going to need that later
Nonces act as counters that keeps track of the number of transactions sent by an account. We're going to need that later
@thirdweb_ This is what the meta-data of the transaction looks like. We need to tell python to transfer from that contract 1 token to a wallet address.
One thing which is important to note, even though im passing a value of 1*10^18, the actual amount of tokens transferred is actually 1
One thing which is important to note, even though im passing a value of 1*10^18, the actual amount of tokens transferred is actually 1
@thirdweb_ Ethereum and Polygon deal with 18 decimals, that's why the number in the metadata is so high
Another thing to note is the chainID. Every blockchain has an ID. 80001 is the ID for the Mumbai testnet
This should look familiar if you dealt with APIs 👇
Never share your private keys
Another thing to note is the chainID. Every blockchain has an ID. 80001 is the ID for the Mumbai testnet
This should look familiar if you dealt with APIs 👇
Never share your private keys
@thirdweb_ And this part basically executes the transaction. We take the metadata, we take the contract, execute the transaction and 'sign' the transaction with the private keys of the owner of the smart contract.
@thirdweb_ This whole process, from smart contract deployment (thirdweb) to interaction with the smart contract(web3) was done with python.
I used 42 lines to execute the transaction and honestly i could've done it in 10-ish lines with thirdweb's sdk. just saying..
bit.ly
I used 42 lines to execute the transaction and honestly i could've done it in 10-ish lines with thirdweb's sdk. just saying..
bit.ly
Loading suggestions...