Sending FLO Coins using Python language
Hello pals!
You can call the RPC directly from your shell/terminal(Windows/Ubuntu) or can write the command in Python. In this post, I’ll guide you to send FLO coins from one node to another node using ‘sendtoaddress’ RPC using Python.
Overview:
- Setting up your wallet for JSON RPC call in FLO Blockchain.
2. Working on RPC ‘sendtoaddress’ to send FLO coins.
3. Adding a string comment along with the transaction in FLO Blockchain.
Setting up your wallet for JSON RPC call in FLO Blockchain.
I have already posted a thread regarding how to set up your wallet for JSON RPC call in FLO Blockchain using Python language. Visit this link.
2. Working on the RPC ‘sendtoaddress’ to send FLO coins.
Note- Make sure your FLO testnet wallet is running.
First of all, you should have a FLO address of receiver to whom you want to send the FLO coins. Now, after setting up your wallet for JSON RPC call in FLO, create a python file, eg- test.py
Open your test.py and write the following commands:
i) from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
# rpc_user and rpc_password are set in the flo.conf file
ii) rpc_connection = AuthServiceProxy(“http://%s:%s@127.0.0.1:17313"%("username", “user_password”))
{Note- Write the username and password you mentioned in .conf file}
iii) address = input(“Enter the FLO address of receiver: “)
iv) amount = input(“Enter the amount to spend: “)
v) send = rpc_connection.sendtoaddress(address,amount)
{Note-Be careful not to give spaces before and after the comma }
Run the file in shell/terminal for accurate results.In your command line, go to the directory containing test.py and write python test.py and fulfill the steps required.
You will get a notification on your screen about the FLO amount sent to the particular address by your FLOwallet. You can also check it by opening your wallet and going to the ‘Transactions’ page.
3.Adding a string comment along with the transaction in FLO Blockchain.
Using FLO blockchain gives you the competitive advantage over other existing blockchains and that is FLO has a uniqueness of adding string comments along with the transactions, which will also be loaded in the blockchain forever. So, you can give an ideal detail in form of comment about your transaction and that can be seen by everyone assessing that blockchain.
Let’s see the steps how we can add a string comment with the transaction:-
We will add some more arguments in the program we used in step 2.
i) from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
# rpc_user and rpc_password are set in the bitcoin.conf file
ii )rpc_connection = AuthServiceProxy(“http://%s:%s@127.0.0.1:17313"%("username", “user_password”))
iii) address = input(“Enter the address of receiver: “)
iv) amount = input(“Enter the amount to send: “)
v) comment = input(“Write the comment what the transaction is for : “)
vi) name = input(“Whom the amount was sent to(name): “)
vii) txComment = input(“Enter your comment for recording in blockchain: “)
viii) send = rpc_connection.sendtoaddress(address,amount,comment,name, False, False, 1, ‘UNSET’, txComment)
The value of ‘txComment’ will get stored in blockchain and is the additional feature FLO provides you. You can check your transaction and your comment at ‘Transactions’ page in your FLO wallet or you can visit https://testnet.flocha.in/ ,where details of each transaction and block in FLO blockchain is stored and updated.
Thank you.