Skip to main content

Deposit API

Reference guide for the BitEscrow Deposit API.

EndpointDescription
/api/deposit/listList deposits by pubkey.
/api/deposit/lockLock a deposit to a contract.
/api/deposit/closeClose a deposit and return funds.
/api/deposit/:dpidFetch a deposit via ID.
/api/deposit/:dpid/cancelCancel a deposit and return funds.

Notice any mistakes, or something missing? Please let us know!
You can submit an issue here: Submit Issue


List Deposits By Pubkey

Request a list of deposits linked to the token's pubkey.

Request Format

method   : 'GET'
endpoint : '/api/deposit/list'
headers : { 'Authorization' : 'Token ' + auth_token }

Response Interface

interface DepositListResponse {
data : {
deposits : DepositData[]
}
}

Example Request

// Generate a request token.
const req = signer.deposit.list()
// Deliver the request and token.
const res = await client.deposit.list(req)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack our response data.
const { deposits } = res.data

See the full code example here.

Related Interfaces:


Read a Deposit By Id

Fetch a deposit from the server by its identifier (dpid).

Request Format

method   : 'GET'
endpoint : '/api/deposit/:dpid'

Response Interface

interface DepositDataResponse {
data : {
deposit : DepositData
}
}

Example Request

// Request to read a deposit via dpid.
const res = await client.deposit.read(dpid)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack the data response
const { deposit } = res.data

See the full code example here.

Example Response

Related Interfaces:


Lock Deposit to a Contract

Lock a deposit to a specific contract.

Request Format

method   : 'POST'
endpoint : '/api/deposit/lock'
headers : { 'content-type' : 'application/json' }
body : JSON.stringify(lock_request)

Request Body

interface LockRequest {
dpid : string
covenant : CovenantData
}

Response Interface

interface FundDataResponse {
data : {
contract : ContractData
deposit : DepositData
}
}

Example Request

// Generate a lock request from the depositor.
const req = signer.deposit.lock(new_contract, open_deposit)
// Deliver the request and token.
const res = await client.deposit.lock(req)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack our response data.
const { contract, deposit } = res.data

See the full code example here.

Related Interfaces:


Close a Deposit

Close a deposit and return the funds (with an updated feerate).

Request Format

method   : 'POST'
endpoint : '/api/deposit/close'
headers : { 'content-type' : 'application/json' }
body : JSON.stringify(close_request)

Request Body

export interface CloseRequest {
dpid : string
return_rate : number
return_psig : string
}

Response Interface

interface DepositDataResponse {
data : {
deposit : DepositData
}
}

Example Request

// Generate a close request from the depositor.
const req = signer.deposit.close(open_deposit, return_rate)
// Deliver the request and token.
const res = await client.deposit.close(req)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack our response data.
const { deposit } = res.data

See the full code example here.

Example Response

Related Interfaces:


Cancel a Deposit

Cancel a deposit and return the funds.

Request Format

method   : 'GET'
endpoint : '/api/deposit/:dpid/cancel'
headers : { 'Authorization' : 'Token ' + auth_token }

Response Interface

interface DepositDataResponse {
data : {
deposit : DepositData
}
}

Example Request

// Generate a close request from the depositor.
const req = signer.deposit.cancel(dpid)
// Deliver the request and token.
const res = await client.deposit.cancel(dpid, req)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack our response data.
const { deposit } = res.data

See the full code example here.

Example Response

Related Interfaces: