ExamplesΒΆ

A basic program that uses python-verge looks like this:

First, import the library and exceptions.

import vergerpc
from vergerpc.exceptions import InsufficientFunds

Then, we connect to the currently running verge instance of the current user on the local machine with one call to connect_to_local(). This returns a VERGEConnection objects:

conn = vergerpc.connect_to_local()

Try to move one verge from account testaccount to account testaccount2 using move(). Catch the InsufficientFunds exception in the case the originating account is broke:

try:
    conn.move("testaccount", "testaccount2", 100.0)
except InsufficientFunds,e:
    print "Account does not have enough funds available!"

Retrieve general server information with getinfo() and print some statistics:

info = conn.getinfo()
print "Blocks: %i" % info.blocks
print "Connections: %i" % info.connections
print "Difficulty: %f" % info.difficulty