Skip to main content

Class: OneTxPayment

OneTxPayment (One Transaction Payment)

Ordinarily payments require more than one transaction, because the payment lifecycle requires more than one permissioned role.

In some use cases, there might be a need for one authorized individual to be able to create, funds, and finalize a payment within a single transaction.

The OneTxPayment extension adds this functionality by adding a makePayment function which requires the caller to have both Funding and administration ability within the domain of the payment.

Extension therefore requires Administration and Funding roles to function.

Note: if you deployed your Colony using the Dapp, the OneTxPayment extension is already installed for you

Constructors

constructor

new OneTxPayment(colony, oneTxPaymentClient)

Parameters

NameType
colonyColony
oneTxPaymentClientOneTxPaymentClientV4

Properties

address

address: string


version

version: number


extensionType

Static extensionType: OneTxPayment = Extension.OneTxPayment


supportedVersions

Static supportedVersions: 4[]

Methods

pay

pay(recipient, amount, teamId?, tokenAddress?): ColonyTxCreator<OneTxPaymentClientV4, "makePaymentFundedFromDomain", { agent?: string ; fundamentalId?: BigNumber ; nPayouts?: BigNumber }, MetadataType>

Make a payment to a single or multiple addresses using one or more tokens

Remarks

Requires the OneTxPayment extension to be installed for the Colony (this is usually the case for Colonies created via the Dapp). Note that most tokens use 18 decimals, so add a bunch of zeros or use our w or toWei functions (see example)

Example

import { Id, Tokens, w } from '@colony/sdk';

// Immediately executing async function
(async function() {
// Pay 10 XDAI (on Gnosis chain) from the root domain to the following address
// (forced transaction example)
await colony.ext.oneTx.pay(
'0xb77D57F4959eAfA0339424b83FcFaf9c15407461',
w`10`,
Id.RootDomain,
Tokens.Gnosis.XDAI,
).tx();
})();

Parameters

NameTypeDescription
recipientstring | string[]Wallet address of account to send the funds to (also awarded reputation when sending the native token) - can also be an array of addresses to pay
amountBigNumberish | BigNumberish[]Amount to pay in wei - can also be an array of amounts for the different tokens
teamId?BigNumberishThe team to use to send the funds from. Has to have funding of at least the amount you need to send. See Colony.moveFundsToTeam. Defaults to the Colony's root team
tokenAddress?string | string[]The address of the token to make the payment in. Default is the Colony's native token - can also be an array of token addresses (needs to be the same length as amount)

Returns

ColonyTxCreator<OneTxPaymentClientV4, "makePaymentFundedFromDomain", { agent?: string ; fundamentalId?: BigNumber ; nPayouts?: BigNumber }, MetadataType>

A transaction creator

Event data

PropertyTypeDescription
agentstringThe address that is responsible for triggering this event
fundamentalIdBigNumberThe newly added payment id
nPayoutsBigNumberNumber of payouts in total

upgrade

upgrade(toVersion?): ColonyTxCreator<ColonyClientV11, "upgradeExtension", { colony?: string ; extensionId?: string ; version?: BigNumber }, MetadataType>

Upgrade this extension to the next or a custom version

This method upgrades this extension to a specified version or, if no version is provided to the next higher version.

Remarks

  • Only users with Root role are allowed to upgrade an extension (or another extension with appropriate permissions)
  • Downgrading of extensions is not possible

Parameters

NameTypeDescription
toVersion?BigNumberishSpecify a custom version to upgrade the extension to

Returns

ColonyTxCreator<ColonyClientV11, "upgradeExtension", { colony?: string ; extensionId?: string ; version?: BigNumber }, MetadataType>

A transaction creator

Event data

PropertyTypeDescription
extensionIdstringExtension id (name of the extension) that was upgraded
oldVersionBigNumberVersion of the colony before the upgrade
newVersionBigNumberVersion of the colony after the upgrade

getLatestSupportedVersion

Static getLatestSupportedVersion(): 4

Returns

4