Accounts#

class defichain.transactions.builder.modules.Accounts(builder)#

The methods of this module create transactions that interact with your account/address.

  1. utxostoaccount: converts the specified amount of UTXO to token

  2. accounttoutxos: converts specified amount of token to UTXO

  3. accounttoaccount: sends token from one address to another address

utxostoaccount(address: str, amount: float | int, tokenId: int = 0, inputs=[]) Transaction#

Creates a transaction that converts the specified amount of UTXO to token

>>> builder.accounts.utxostoaccount("df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e", 1) # converts one UTXO to token
Parameters:
  • address (str) – (required) the address of the account to be converted from

  • amount (float | int) – (required) the amount of UTXOs to convert to token

  • tokenId (int) – (optional) the token id of the converted token (default: 0 -> DFI)

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction

accounttoutxos(addressFrom: str, addressAmountTo: {}, inputs=[]) Transaction#

Creates a transaction that converts specified amount of token to UTXO

>>> builder.accounts.accounttoutxos("df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e", {"df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e": "1@DFI", "df1qzfwy63ggj5jfpul7r04kn2ss8kjz2sda57fa4m": "1@DFI"}) # converts two token to UTXO
Parameters:
  • addressFrom (str) – (required) the address of the account to be converted from

  • addressAmountTo (Address Amounts) – (required) json with specified address and amount to send

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction

accounttoaccount(addressFrom: str, addressAmountTo: {}, inputs=[]) Transaction#

Creates a transaction that sends token from one address to another address

>>> builder.accounts.accounttoaccount("df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e", {"df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e": "0.00001@BTC", "df1qzfwy63ggj5jfpul7r04kn2ss8kjz2sda57fa4m": "1@DFI"}) # sends 0.00001 BTC and 1 DFI to other addresses
Parameters:
  • addressFrom (str) – (required) address from which the tokens should be sent

  • addressAmountTo (Address Amounts) – (required) json with specified address and amount to send

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction