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
Name | Type |
---|---|
colony | Colony |
oneTxPaymentClient | OneTxPaymentClientV4 |
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
Name | Type | Description |
---|---|---|
recipient | string | 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 |
amount | BigNumberish | BigNumberish [] | Amount to pay in wei - can also be an array of amounts for the different tokens |
teamId? | BigNumberish | The 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
Property | Type | Description |
---|---|---|
agent | string | The address that is responsible for triggering this event |
fundamentalId | BigNumber | The newly added payment id |
nPayouts | BigNumber | Number of payouts in total |
upgrade
▸ upgrade(toVersion?
): ColonyTxCreator
<ColonyClientV12
, "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
Name | Type | Description |
---|---|---|
toVersion? | BigNumberish | Specify a custom version to upgrade the extension to |
Returns
ColonyTxCreator
<ColonyClientV12
, "upgradeExtension"
, { colony?
: string
; extensionId?
: string
; version?
: BigNumber
}, MetadataType
>
A transaction creator
Event data
Property | Type | Description |
---|---|---|
extensionId | string | Extension id (name of the extension) that was upgraded |
oldVersion | BigNumber | Version of the colony before the upgrade |
newVersion | BigNumber | Version of the colony after the upgrade |
getLatestSupportedVersion
▸ Static
getLatestSupportedVersion(): 4
Returns
4