peerplays.peerplays module¶
-
class
peerplays.peerplays.
PeerPlays
(node='', rpcuser='', rpcpassword='', debug=False, skip_wallet_init=False, **kwargs)¶ Bases:
graphenecommon.chain.AbstractGrapheneChain
Connect to the PeerPlays network.
Parameters: - node (str) – Node to connect to (optional)
- rpcuser (str) – RPC user (optional)
- rpcpassword (str) – RPC password (optional)
- nobroadcast (bool) – Do not broadcast a transaction! (optional)
- debug (bool) – Enable Debugging (optional)
- keys (array,dict,string) – Predefine the wif keys to shortcut the wallet database (optional)
- offline (bool) – Boolean to prevent connecting to network (defaults
to
False
) (optional) - proposer (str) – Propose a transaction using this proposer (optional)
- proposal_expiration (int) – Expiration time (in seconds) for the proposal (optional)
- proposal_review (int) – Review period (in seconds) for the proposal (optional)
- expiration (int) – Delay in seconds until transactions are supposed to expire (optional)
- blocking (str) – Wait for broadcasted transactions to be included in a block and return full transaction (can be “head” or “irrversible”)
- bundle (bool) – Do not broadcast transactions right away, but allow to bundle operations (optional)
Three wallet operation modes are possible:
- Wallet Database: Here, the peerplayslibs load the keys from the
locally stored wallet SQLite database (see
storage.py
). To use this mode, simply callPeerPlays()
without thekeys
parameter - Providing Keys: Here, you can provide the keys for
your accounts manually. All you need to do is add the wif
keys for the accounts you want to use as a simple array
using the
keys
parameter toPeerPlays()
. - Force keys: This more is for advanced users and
requires that you know what you are doing. Here, the
keys
parameter is a dictionary that overwrite theactive
,owner
, ormemo
keys for any account. This mode is only used for foreign signatures!
If no node is provided, it will connect to the node of http://ppy-node.peerplays.eu. It is highly recommended that you pick your own node instead. Default settings can be changed with:
peerplays set node <host>
where
<host>
starts withws://
orwss://
.The purpose of this class it to simplify interaction with PeerPlays.
The idea is to have a class that allows to do this:
from peerplays import PeerPlays peerplays = PeerPlays() print(peerplays.info())
All that is requires is for the user to have added a key with
peerplays
peerplays addkey
and setting a default author:
peerplays set default_account xeroc
This class also deals with edits, votes and reading content.
-
allow
(foreign, weight=None, permission='active', account=None, threshold=None, **kwargs)¶ Give additional access to an account by some other public key or account.
Parameters: - foreign (str) – The foreign account that will obtain access
- weight (int) – (optional) The weight to use. If not define, the threshold will be used. If the weight is smaller than the threshold, additional signatures will be required. (defaults to threshold)
- permission (str) – (optional) The actual permission to
modify (defaults to
active
) - account (str) – (optional) the account to allow access
to (defaults to
default_account
) - threshold (int) – The threshold that needs to be reached by signatures to be able to interact
-
approvecommittee
(committees, account=None, **kwargs)¶ Approve a committee
Parameters: - committees (list) – list of committee member name or id
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
approveproposal
(proposal_ids, account=None, approver=None, **kwargs)¶ Approve Proposal
Parameters: - proposal_id (list) – Ids of the proposals
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
approvewitness
(witnesses, account=None, **kwargs)¶ Approve a witness
Parameters: - witnesses (list) – list of Witness name or id
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
bet_cancel
(bet_to_cancel, account=None, **kwargs)¶ Cancel a bet
Parameters: - bet_to_cancel (str) – The identifier that identifies the bet to cancel
- account (str) – (optional) the account that owns the bet
(defaults to
default_account
)
-
bet_place
(betting_market_id, amount_to_bet, backer_multiplier, back_or_lay, account=None, **kwargs)¶ Place a bet
Parameters: - betting_market_id (str) – The identifier for the market to bet in
- amount_to_bet (peerplays.amount.Amount) – Amount to bet with
- backer_multiplier (int) – Multipler for backer
- back_or_lay (str) – “back” or “lay” the bet
- account (str) – (optional) the account to bet (defaults
to
default_account
)
-
betting_market_create
(payout_condition, description, group_id='0.0.0', account=None, **kwargs)¶ Create an event group. This needs to be proposed.
Parameters: - payout_condition (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- description (list) – Internationalized descriptions, e.g.
[['de', 'Foo'], ['en', 'bar']]
- group_id (str) – Group ID to create the market for (defaults to
relative id
0.0.0
) - account (str) – (optional) the account to allow access
to (defaults to
default_account
)
- payout_condition (list) – Internationalized names, e.g.
-
betting_market_group_create
(description, event_id='0.0.0', rules_id='0.0.0', asset=None, delay_before_settling=0, never_in_play=False, resolution_constraint='exactly_one_winner', account=None, **kwargs)¶ Create an betting market. This needs to be proposed.
Parameters: - description (list) – Internationalized list of descriptions
- event_id (str) – Event ID to create this for (defaults to
relative id
0.0.0
) - rule_id (str) – Rule ID to create this with (defaults to
relative id
0.0.0
) - asset (peerplays.asset.Asset) – Asset to be used for this market
- delay_before_settling (int) – Delay in seconds before settling (defaults to 0 seconds - immediatelly)
- never_in_play (bool) – Set this market group as never in play (defaults to False)
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
betting_market_group_update
(betting_market_group_id, description=None, event_id=None, rules_id=None, status=None, account=None, **kwargs)¶ Update an betting market. This needs to be proposed.
Parameters: - betting_market_group_id (str) – Id of the betting market group to update
- description (list) – Internationalized list of descriptions
- event_id (str) – Event ID to create this for
- rule_id (str) – Rule ID to create this with
- status (str) – New Status
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
betting_market_resolve
(betting_market_group_id, results, account=None, **kwargs)¶ Create an betting market. This needs to be proposed.
Parameters: - betting_market_group_id (str) – Market Group ID to resolve
- results (list) – Array of Result of the market (
win
,not_win
, orcancel
) - account (str) – (optional) the account to allow access
to (defaults to
default_account
)
Results take the form::
[ ["1.21.257", "win"], ["1.21.258", "not_win"], ["1.21.259", "cancel"], ]
-
betting_market_rules_create
(names, descriptions, account=None, **kwargs)¶ Create betting market rules
Parameters: - names (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- descriptions (list) – Internationalized descriptions, e.g.
[['de', 'Foo'], ['en', 'bar']]
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
- names (list) – Internationalized names, e.g.
-
betting_market_rules_update
(rules_id, names, descriptions, account=None, **kwargs)¶ Update betting market rules
Parameters: - rules_id (str) – Id of the betting market rules to update
- names (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- descriptions (list) – Internationalized descriptions, e.g.
[['de', 'Foo'], ['en', 'bar']]
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
betting_market_update
(betting_market_id, payout_condition, description, group_id='0.0.0', account=None, **kwargs)¶ Update an event group. This needs to be proposed.
Parameters: - betting_market_id (str) – Id of the betting market to update
- payout_condition (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- description (list) – Internationalized descriptions, e.g.
[['de', 'Foo'], ['en', 'bar']]
- group_id (str) – Group ID to create the market for (defaults to
relative id
0.0.0
) - account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
broadcast
(tx=None)¶ Broadcast a transaction to the Blockchain
Parameters: tx (tx) – Signed transaction to broadcast
-
cancel
(orderNumbers, account=None, **kwargs)¶ Cancels an order you have placed in a given market. Requires only the “orderNumbers”. An order number takes the form
1.7.xxx
.Parameters: orderNumbers (str) – The Order Object ide of the form 1.7.xxxx
-
cancel_offer
(issuer_account_id_or_name, offer_id, **kwargs)¶
-
clear
()¶
-
clear_cache
()¶ Clear Caches
-
connect
(node='', rpcuser='', rpcpassword='', **kwargs)¶ Connect to blockchain network (internal use only)
-
create_account
(account_name, registrar=None, referrer='1.2.0', referrer_percent=50, owner_key=None, active_key=None, memo_key=None, password=None, additional_owner_keys=[], additional_active_keys=[], additional_owner_accounts=[], additional_active_accounts=[], proxy_account='proxy-to-self', storekeys=True, **kwargs)¶ Create new account on PeerPlays
The brainkey/password can be used to recover all generated keys (see peerplaysbase.account for more details.
By default, this call will use
default_account
to register a new nameaccount_name
with all keys being derived from a new brain key that will be returned. The corresponding keys will automatically be installed in the wallet.Warning
Don’t call this method unless you know what you are doing! Be sure to understand what this method does and where to find the private keys for your account.
Note
Please note that this imports private keys (if password is present) into the wallet by default. However, it does not import the owner key for security reasons. Do NOT expect to be able to recover it from the wallet if you lose your password!
Parameters: - account_name (str) – (required) new account name
- registrar (str) – which account should pay the registration fee
(defaults to
default_account
) - owner_key (str) – Main owner key
- active_key (str) – Main active key
- memo_key (str) – Main memo_key
- password (str) – Alternatively to providing keys, one can provide a password from which the keys will be derived
- additional_owner_keys (array) – Additional owner public keys
- additional_active_keys (array) – Additional active public keys
- additional_owner_accounts (array) – Additional owner account names
- additional_active_accounts (array) – Additional acctive account names
- storekeys (bool) – Store new keys in the wallet (default:
True
)
Raises: AccountExistsException – if the account already exists on the blockchain
-
create_bid
(bidder_account_id_or_name, bid_price, offer_id, **kwargs)¶
-
create_offer
(item_ids, issuer_id_or_name, minimum_price, maximum_price, buying_item, offer_expiration_date, memo=None, **kwargs)¶
-
custom_permission_create
(permission_name, owner_account=None, weight_threshold=[], account_auths=[], key_auths=[], address_auths=[], **kwargs)¶
-
custom_permission_delete
(permission_id, owner_account=None, **kwargs)¶
-
custom_permission_update
(permission_id, owner_account=None, weight_threshold=[], account_auths=[], key_auths=[], address_auths=[], **kwargs)¶
-
define_classes
()¶
-
deleteproposal
(proposal_id, account=None, **kwargs)¶
-
disallow
(foreign, permission='active', account=None, threshold=None, **kwargs)¶ Remove additional access to an account by some other public key or account.
Parameters: - foreign (str) – The foreign account that will obtain access
- permission (str) – (optional) The actual permission to
modify (defaults to
active
) - account (str) – (optional) the account to allow access
to (defaults to
default_account
) - threshold (int) – The threshold that needs to be reached by signatures to be able to interact
-
disapprovecommittee
(committees, account=None, **kwargs)¶ Disapprove a committee
Parameters: - committees (list) – list of committee name or id
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
disapproveproposal
(proposal_ids, account=None, approver=None, **kwargs)¶ Disapprove Proposal
Parameters: - proposal_ids (list) – Ids of the proposals
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
disapprovewitness
(witnesses, account=None, **kwargs)¶ Disapprove a witness
Parameters: - witnesses (list) – list of Witness name or id
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
event_create
(name, season, start_time, event_group_id='0.0.0', account=None, **kwargs)¶ Create an event. This needs to be proposed.
Parameters: - name (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- season (list) – Internationalized season, e.g.
[['de', 'Foo'], ['en', 'bar']]
- event_group_id (str) – Event group ID to create the event for
(defaults to relative id
0.0.0
) - start_time (datetime) – Time of the start of the event
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
- name (list) – Internationalized names, e.g.
-
event_group_create
(names, sport_id='0.0.0', account=None, **kwargs)¶ Create an event group. This needs to be proposed.
Parameters: - names (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- sport_id (str) – Sport ID to create the event group for
(defaults to relative id
0.0.0
) - account (str) – (optional) the account to allow access
to (defaults to
default_account
)
- names (list) – Internationalized names, e.g.
-
event_group_update
(event_group_id, names=[], sport_id='0.0.0', account=None, **kwargs)¶ Update an event group. This needs to be proposed.
Parameters: - event_id (str) – Id of the event group to update
- names (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- sport_id (str) – Sport ID to create the event group for
(defaults to relative id
0.0.0
) - account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
event_update
(event_id, name=None, season=None, start_time=None, event_group_id=None, status=None, account=None, **kwargs)¶ Update an event. This needs to be proposed.
Parameters: - event_id (str) – Id of the event to update
- name (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- season (list) – Internationalized season, e.g.
[['de', 'Foo'], ['en', 'bar']]
- event_group_id (str) – Event group ID to create the event for
(defaults to relative id
0.0.0
) - start_time (datetime) – Time of the start of the event
- status (str) – Event status
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
event_update_status
(event_id, status, scores=[], account=None, **kwargs)¶ Update the status of an event. This needs to be proposed.
Parameters: - event_id (str) – Id of the event to update
- status (str) – Event status
- scores (list) – List of strings that represent the scores of a match (defaults to [])
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
eventgroup_delete
(event_group_id='0.0.0', account=None, **kwargs)¶ Delete an eventgroup. This needs to be propose.
Parameters: - event_group_id (str) – ID of the event group to be deleted
- account (str) – (optional) Account used to verify the operation
-
finalizeOp
(ops, account, permission, **kwargs)¶ This method obtains the required private keys if present in the wallet, finalizes the transaction, signs it and broadacasts it
Parameters: - ops (operation) – The operation (or list of operaions) to broadcast
- account (operation) – The account that authorizes the operation
- permission (string) – The required permission for signing (active, owner, posting)
- append_to (object) – This allows to provide an instance of
ProposalsBuilder (see
new_proposal()
) or TransactionBuilder (seenew_tx()
) to specify where to put a specific operation.
- … note::
append_to
is exposed to every method used in the - this class
… note:
If ``ops`` is a list of operation, they all need to be signable by the same key! Thus, you cannot combine ops that require active permission with ops that require posting permission. Neither can you use different accounts for different operations!
- … note:: This uses
txbuffer
as instance of transactionbuilder.TransactionBuilder
. You may want to use your own txbuffer
-
info
()¶ Returns the global properties
-
is_connected
()¶
-
newWallet
(pwd)¶
-
new_proposal
(parent=None, proposer=None, proposal_expiration=None, proposal_review=None, **kwargs)¶
-
new_tx
(*args, **kwargs)¶ Let’s obtain a new txbuffer
Returns int txid: id of the new txbuffer
-
new_wallet
(pwd)¶ Create a new wallet. This method is basically only calls
wallet.Wallet.create()
.Parameters: pwd (str) – Password to use for the new wallet Raises: exceptions.WalletExists – if there is already a wallet created
-
nft_approve
(operator_, approved, token_id, **kwargs)¶
-
nft_metadata_create
(owner_account_id_or_name, name, symbol, base_uri, revenue_partner=None, revenue_split=200, is_transferable=True, is_sellable=True, role_id=None, max_supply=None, lottery_options=None, **kwargs)¶
-
nft_metadata_update
(owner_account_id_or_name, nft_metadata_id, name, symbol, base_uri, revenue_partner=None, revenue_split=200, is_transferable=True, is_sellable=True, role_id=None, **kwargs)¶
-
nft_mint
(metadata_owner_account_id_or_name, metadata_id, owner_account_id_or_name, approved_account_id_or_name, approved_operators, token_uri, **kwargs)¶
-
nft_safe_transfer_from
(operator_, from_, to_, token_id, data, **kwargs)¶
-
nft_set_approval_for_all
(owner, operator_, approved, **kwargs)¶
-
prefix
¶ Contains the prefix of the blockchain
-
propbuffer
¶ Return the default proposal buffer
-
proposal
(proposer=None, proposal_expiration=None, proposal_review=None)¶ Return the default proposal buffer
- … note:: If any parameter is set, the default proposal
- parameters will be changed!
-
set_blocking
(block=True)¶ This sets a flag that forces the broadcast to block until the transactions made it into a block
-
set_default_account
(account)¶ Set the default account to be used
This method allows to set the current instance as default
-
sign
(tx=None, wifs=[])¶ Sign a provided transaction witht he provided key(s)
Parameters: - tx (dict) – The transaction to be signed and returned
- wifs (string) – One or many wif keys to use for signing a transaction. If not present, the keys will be loaded from the wallet as defined in “missing_signatures” key of the transactions.
-
sport_create
(names, account=None, **kwargs)¶ Create a sport. This needs to be proposed.
Parameters: - names (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
- names (list) – Internationalized names, e.g.
-
sport_delete
(sport_id='0.0.0', account=None, **kwargs)¶ Remove a sport. This needs to be proposed.
Parameters: - sport_id (str) – Sport ID to identify the Sport to be deleted
- account (str) – (optional) Account used to verify the operation
-
sport_update
(sport_id, names=[], account=None, **kwargs)¶ Update a sport. This needs to be proposed.
Parameters: - sport_id (str) – The id of the sport to update
- names (list) – Internationalized names, e.g.
[['de', 'Foo'], ['en', 'bar']]
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
transfer
(to, amount, asset, memo='', account=None, **kwargs)¶ Transfer an asset to another account.
Parameters: - to (str) – Recipient
- amount (float) – Amount to transfer
- asset (str) – Asset to transfer
- memo (str) – (optional) Memo, may begin with # for encrypted messaging
- account (str) – (optional) the source account for the transfer
if not
default_account
-
tx
()¶ Returns the default transaction buffer
-
txbuffer
¶ Returns the currently active tx buffer
-
unlock
(*args, **kwargs)¶ Unlock the internal wallet
-
update_memo_key
(key, account=None, **kwargs)¶ Update an account’s memo public key
This method does not add any private keys to your wallet but merely changes the memo public key.
Parameters: - key (str) – New memo public key
- account (str) – (optional) the account to allow access
to (defaults to
default_account
)
-
upgrade_account
(account=None, **kwargs)¶ Upgrade an account to Lifetime membership
Parameters: account (str) – (optional) the account to allow access to (defaults to default_account
)