BitShares Forum
Main => Technical Support => Topic started by: sharique-knysys on February 24, 2016, 10:19:15 am
-
Hi
I am using graphenelib and I want to transfer some currency to another account. What is the process? I have found the docs of graphenelib but it says use this line to transfer res = client.transfer("sender","receiver","5", "USD", "memo", True); on this link http://python-graphenelib.readthedocs.org/en/latest/rpc.html. I don't know how to use this code. Please share the code with me so I can transfer amount from my account.
-
I have found the scripts on this link. Now I want to transfer currency. How can I use previous account with wallet to transfer currency to other account
-
Here is some more docs;
http://python-graphenelib.readthedocs.org/en/latest/client.html
Example:
from grapheneapi.grapheneclient import GrapheneClient
class Config():
wallet_host = "localhost"
wallet_port = 8092
client = GrapheneClient(Config)
res = client.rpc.transfer("sender","receiver","5", "USD", "memo", True);
-
or
from grapheneapi import GrapheneAPI
rpc = GrapheneAPI("localhost", 8092, "", "")
res = rpc.transfer("sender","receiver","5", "USD", "memo", True);
note that I use rpc.transfer instead of client.transfer!
-
I have used that api. First of all I made witness node and wallet which runs on port 8090 and 8092 respectively, then connect to that api with above code. Import desired private key into cli_wallet(with command line) and run above code, this code can transfer funds from one account to another. In this code you mentioned localhost. My first question is how can I connect to remote host? My second question is how can I import private key through python code then transfer funds to other account? Or is there any rpc api of graphene for transferring funds. I used following code but it is not working. Can anybody tell me what is missing in that code?
import json
from grapheneapi import GrapheneAPI
if __name__ == '__main__':
client = GrapheneAPI("wss://bitshares.openledger.info/ws", 443, "", "")
res = client.transfer("fromaccount", "toaccount", "10", "BTS", "Sending 10 BTS", True);
-
- Instead of putting "localhost" for your wallet .. you can also use an IP address or a fully qualifying domain, e.g. mywallet.mydomain.com
- You can import private keys into your wallet with python the same way you would do it with the cli-wallet.. somthing along the lines of
client.rpc.import_key("accountname", "privatekey")
- Transfers are initated by calling 'transfer' in the cli-wallet .. that call can be done with RPC as well and is available via
client.rpc.transfer(from, to, amount, asset, memo, True)
As to your code .. please take a closer look at http://docs.bitshares.eu/api/#interfacing-with-graphene
the websocket server (as indicated with the "wss") does not offer a transfer API .. it is the full node and can only poll data from the blockchain.
you need to run a cli wallet locally and connect your python to that wallet ..