Skip to content

Latest commit

 

History

History
101 lines (56 loc) · 11.9 KB

File metadata and controls

101 lines (56 loc) · 11.9 KB

createRequest()

Description

Create an unencrypted request

Parameters

NameTypeRequired?Description
parametersICreateRequestParameterstrueParameters to create a request
optionsICreateRequestOptionsfalseOptions to create a request

Returns

Promise<Request>

Types and Interfaces

ICreateRequestParameters

NameTypeRequired?Description
requestInfoIRequestInfotrueCore request contents
signerIIdentitytrueIdentity of the creator and signer of the request. Must be either the payee or payer.
paymentNetworkPaymentNetworkCreateParametersfalsePayment method
topicsstring[]falseList of hashes, usually one for each of the request stakeholders
contentDataObjectfalseAdditional arbitrary request contents
disablePaymentDetectionbooleanfalseDisable payment detection
disableEventsbooleanfalseDiable event callbacks

ICreateRequestOptions

NameTypeRequriedDescription
skipRefreshbooleanfalseDisable the request refresh after creation. Warning: the balance will be null.

IRequestInfo

NameTypeRequired?Description
currencystring | ICurrencytrueThe currency in which the request is denominated. Not necessarily the currency in which the payment will occur.
expectedAmountnumber | stringtrueThe requested amount in machine-readable integer units.
payeeIIdentityfalseIdentity of the payee. Required if payer not set
payerIIdentityfalseIdentity of the payer. Required if payee not set
extensionsDataany[]falseRaw extensionsData. Not recommended. Prefer contentData and paymentNetwork instead.
timestampnumber (Unix timestamp)falseTimestamp when request is created. User provided, so this is an agreement between payee and payer.
noncenumberfalseOptional nonce to differentiate identical requests created at the same timestamp.

PaymentNetworkCreateParameters

NameTypeRequiredDescription
idTypes.Extension.PAYMENT_NETWORK_IDtruePayment network ID
parametersICreationParameterstruePayment network parameters. Contents depend on id

ICurrency

NameTypeRequired?Description
typeTypes.RequestLogic.CURRENCYtrueCurrency type
valuestringtrue

Depends on type.

  • ERC20 contract address '0x123'
  • Fiat symbol 'USD'
  • Native symbol 'ETH'
networkChainNamefalseThe chain on which the currency exists

Types.RequestLogic.CURRENCY

NameValue
ETH'ETH'Native (ETH, XDAI, etc.)
BTC'BTC'Bitcoin
ISO4217'ISO4217'Fiat (USD, EUR, etc.)
ERC20'ERC20'Non-native fungible currency (USDC, REQ, etc.)
ERC777'ERC777'Streamable fungible currency (USDCx, REQx, etc.)

Types.Extension.PAYMENT_NETWORK_ID

NameValueDescription
ANY_DECLARATIVE'pn-any-declarative'Payer declares payment sent. Payee declares payment received.
ANY_TO_ERC20_PROXY'pn-any-to-erc20-proxy'Swap to ERC20 before sending to payee
ANY_TO_ETH_PROXY'pn-any-to-eth-proxy'Swap to native token before sending to payee. Only works on EVM-compatible chains.
ANY_TO_NATIVE_TOKEN'pn-any-to-native-token'Swap to native token before sending to payee. Only works on NEAR.
BITCOIN_ADDRESS_BASED'pn-bitcoin-address-based'Payee generates a new Bitcoin address. Use block explorer to detect all payments to that address.
ERC20_ADDRESS_BASED'pn-erc20-address-based'Payee generates a new Ethereum address. Use block explorer to detect all payments to that address.
ERC20_FEE_PROXY_CONTRACT'pn-erc20-fee-proxy-contract'Send ERC20 via smart contract with an optional fee.
ERC20_PROXY_CONTRACT'pn-erc20-proxy-contract'Send ERC20 via smart contract
ERC20_TRANSFERABLE_RECEIVABLE'pn-erc20-transferable-receivable'Mint a Request as an NFT. The holder receives the payment.
ERC777_STREAM'pn-erc777-stream'Superfluid stream
ETH_FEE_PROXY_CONTRACT'pn-eth-fee-proxy-contract'Send native token via smart contract with an optional fee.
ETH_INPUT_DATA'pn-eth-input-data'Send native token with paymentReference in the call data.
NATIVE_TOKEN'pn-native-token'Send native token via smart contract with an optional fee on NEAR.
TESTNET_BITCOIN_ADDRESS_BASED'pn-testnet-bitcoin-address-based'Payee generates a new Bitcoin testnet address. Use block explorer to detect all payments to that address.

{% hint style="info" %} Escrow payments use the ERC20_FEE_PROXY_CONTRACT payment network. {% endhint %}

ICreationParameters

graph TD
  PnAnyDeclarative.ICreationParameters --> PnAddressBased.ICreationParameters
  PnAddressBased.ICreationParameters --> PnReferenceBased.ICreationParameters
  PnReferenceBased.ICreationParameters --> PnFeeReferenceBased.ICreationParameters
  PnReferenceBased.ICreationParameters --> PnStreamReferenceBased.ICreationParameters
  PnFeeReferenceBased.ICreationParameters --> PnAnyToAnyConversion.ICreationParameters
  PnAnyToAnyConversion.ICreationParameters --> PnAnyToErc20.ICreationParameters
  PnAnyToAnyConversion.ICreationParameters --> PnAnyToEth.ICreationParameters
Loading

PnAnyDeclarative.ICreationParameters

NameTypeRequiredDescription
paymentInfoanyfalse
refundInfoanyfalse
payeeDelegateIIdentityfalseIdentity that can update the request on behalf of the payee
payerDelegateIIdentityfalseIdentity that can update the request on behalf of the payer
saltstringfalseA random number with at least 8 bytes of randomness. It must be unique to each request

PnAddressBased.ICreationParameters

NameTypeRequiredDescription
paymentAddressstringfalseThe payment recipient address
refundAddressstringfalseThe refund recipient address

PnReferenceBased.ICreationParameters

NameTypeRequiredDescription
saltstringfalse
paymentNetworkNameChainNamefalseThe chain name on which the payment will occur

PnFeeReferenceBased.ICreationParameters

NameTypeRequiredDescription
feeAddressstringfalseThe address to which fees will be sent
feeAmountstringfalseThe fee amount in machine-readable integer units

PnAnyToAnyConversion.ICreationParameters

NameTypeRequiredDescription
maxRateTimespannumberfalseThe maximum acceptable time span between the payment and the conversion rate timestamp
networkChainNamefalseThe network of the tokens accepted for payments

PnAnyToErc20.ICreationParameters

NameTypeRequiredDescription
acceptedTokensstring[]falseA list of token addresses accepted for payments and refunds
networkEvmChainNamefalsethe network of the tokens accepted for payments

PnAnyToEth.ICreationParameters

Identical to PnAnyToAnyConversion.ICreationParameters

PnStreamReferenceBased.ICreationParameters

Equal to IOriginalRequestCreationParameters OR ISubsequentRequestCreationParameters

IOriginalRequestCreationParameters

NameTypeRequiredDescription
expectedFlowRatestringtrue
expectedStartDatestringtrue

ISubsequentRequestCreationParameters

NameTypeRequiredDescription
previousRequestIdstringtrue
originalRequestIdstringtrue
recurrenceNumberstringtrue