Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
353 lines (229 sloc) 4.62 KB

Client Method Reference

All methods return promises.

Core Channel Management Methods

transfer

Makes a simple end-to-end transfer from one user's balance to another.

transfer: (TransferParams) =>  Promise<ChannelState>

Example

const payload: TransferParams = { 
  recipient: "0xabcdef"
  meta: "Metadata for transfer"
  amount: "1000" // in Wei
  assetId: "0x0" // represents ETH
}

await transfer(payload)

deposit

Deposits funds from a user's onchain wallet to a channel.

deposit: (DepositParams) => Promise<ChannelState>

Example

// Making a deposit in ETH
const payload: AssetAmount = { 
  amount: '0x3abc', // represented as bignumber
  assetId: '0x0'    // i.e. Eth
}

deposit(payload)

exchange

Conducts an in-flight swap from one asset to another.

exchange: (ExchangeParams) => Promise<ChannelState>

Example

const payload: ExchangeParams = { 
  amount: "100" // in Wei
  toAssetId: "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" // Dai
  fromAssetId: "0x0" // ETH
}

await exchange(payload)

on

Starts an event listener for channel events. See Advanced - Event Monitoring for a list of channel events.

on: (event: ConnextEvent, (cb: any => any) => void) => void

Example

connext.on("DEPOSIT_STARTED", () => 
            { console.log("Your deposit has begun")
              this.showDepositStarted()
            });g

redeem

Redeems a transfer using a secret pregenerated by the sender. Useful for onboarding / airdropping.

redeem: (string) => Promise<string>

Example

withdraw

Withdraws funds from a channel to a specified onchain recipient.

withdraw: (WithdrawParams) => Promise<ChannelState>

Example

const payload: WithdrawParams = { 
  recipient: // defaults to signer
  amount: "100"
  assetId: "0x0"
}

await withdraw(payload)

Generalized State Methods

installApp

installApp: (InstallAppParams) => Promise<ChannelState>

Example

uninstallApp

uninstallApp: (UninstallAppParams) => Promise<ChannelState>

Example

takeAction

takeAction: (takeActionParams) => Promise<AppState>

Example

getHistory

getHistory: () => Promise<AppState[]>

Example

getHistoryById

getHistoryById: (id) => Promise<AppState>

Example

getProfileConfig

getProfileConfig: () => Promise<PaymentProfile>

Example

startProfileSession

startProfileSession: (string) => Promise<void>

Example

getChannelState

getChannelState: () => Promise<ChannelState>

Example

getAppState

getAppState: (string) => Promise<AppState>

Example

getApps

getApps: () => Promise<string[]>

Example

getFreeBalance

getFreeBalance: () => //TODO

Example

Low Level Channel API (mapped to CF node)

createChannel

createChannel: () => Promise<string>

Example

proposeInstall

proposeInstall: (LowLevelProposeInstallParams) => Promise<string>

Example

install

install: (LowLevelInstallParams) => Promise<AppInstance>

Example

rejectInstall

rejectInstall: (LowLevelRejectInstallParams) => void

Example

proposeInstallVirtual

proposeInstallVirtual: (LowLevelProposeInstallVirtualParams) => Promise<string>

Example

installVirtual

installVirtual: (LowLevelInstallVirtualParams) => Promise<AppInstance>

Example

proposeState

proposeState: (LowLevelProposeStateParams) => //TODO (CF)

Example

updateState

updateState: (LowLevelUpdateStateParams) => //TODO (CF)

Example

rejectState

rejectState: (LowLevelRejectStateParams) => //TODO (CF)

Example

getProposedAppInstance

getProposedAppInstance: () => Promise<AppInstance[]>

Example

You can’t perform that action at this time.