Browser API documentation
Last updated
Last updated
The main class for this package. Has methods for receiving order events and sending orders through the 0x Mesh network.
Mesh
+ new Mesh(config
: Config): Mesh
Defined in mesh.ts:141
Instantiates a new Mesh instance.
Parameters:
Returns: Mesh
An instance of Mesh
▸ addOrdersAsync(orders
: SignedOrder[], pinned
: boolean): Promise‹ValidationResults›
Defined in mesh.ts:291
Validates and adds the given orders to Mesh. If an order is successfully added, Mesh will share it with any peers in the network and start watching it for changes (e.g. filled, canceled, expired). The returned promise will only be rejected if there was an error validating or adding the order; it will not be rejected for any invalid orders (check results.rejected instead).
Parameters:
Returns: Promise‹ValidationResults›
Validation results for the given orders, indicating which orders were accepted and which were rejected.
▸ getOrdersAsync(perPage
: number): Promise‹GetOrdersResponse›
Defined in mesh.ts:220
Get all 0x signed orders currently stored in the Mesh node
Parameters:
Returns: Promise‹GetOrdersResponse›
the snapshotID, snapshotTimestamp and all orders, their hashes and fillableTakerAssetAmounts
▸ getOrdersForPageAsync(page
: number, perPage
: number, snapshotID?
: undefined | string): Promise‹GetOrdersResponse›
Defined in mesh.ts:262
Get page of 0x signed orders stored on the Mesh node at the specified snapshot
Parameters:
Returns: Promise‹GetOrdersResponse›
the snapshotID, snapshotTimestamp and all orders, their hashes and fillableTakerAssetAmounts
▸ getStatsAsync(): Promise‹Stats›
Defined in mesh.ts:203
Returns various stats about Mesh, including the total number of orders and the number of peers Mesh is connected to.
Returns: Promise‹Stats›
▸ onError(handler
: function): void
Defined in mesh.ts:161
Registers a handler which will be called in the event of a critical error. Note that the handler will not be called for non-critical errors. In order to ensure no errors are missed, this should be called before startAsync.
Parameters:
▪ handler: function
The handler to be called.
▸ (err
: Error): void
Parameters:
Returns: void
▸ onOrderEvents(handler
: function): void
Defined in mesh.ts:176
Registers a handler which will be called for any incoming order events. Order events are fired whenver an order is added, canceled, expired, or filled. In order to ensure no events are missed, this should be called before startAsync.
Parameters:
▪ handler: function
The handler to be called.
▸ (events
: OrderEvent[]): void
Parameters:
Returns: void
▸ startAsync(): Promise‹void›
Defined in mesh.ts:187
Starts the Mesh node in the background. Mesh will automatically find peers in the network and begin receiving orders from them.
Returns: Promise‹void›
• ERC1155ApprovalForAllEvent: = "ERC1155ApprovalForAllEvent"
Defined in types.ts:444
• ERC1155TransferBatchEvent: = "ERC1155TransferBatchEvent"
Defined in types.ts:446
• ERC1155TransferSingleEvent: = "ERC1155TransferSingleEvent"
Defined in types.ts:445
• ERC20ApprovalEvent: = "ERC20ApprovalEvent"
Defined in types.ts:440
• ERC20TransferEvent: = "ERC20TransferEvent"
Defined in types.ts:439
• ERC721ApprovalEvent: = "ERC721ApprovalEvent"
Defined in types.ts:442
• ERC721ApprovalForAllEvent: = "ERC721ApprovalForAllEvent"
Defined in types.ts:443
• ERC721TransferEvent: = "ERC721TransferEvent"
Defined in types.ts:441
• ExchangeCancelEvent: = "ExchangeCancelEvent"
Defined in types.ts:448
• ExchangeCancelUpToEvent: = "ExchangeCancelUpToEvent"
Defined in types.ts:449
• ExchangeFillEvent: = "ExchangeFillEvent"
Defined in types.ts:447
• WethDepositEvent: = "WethDepositEvent"
Defined in types.ts:450
• WethWithdrawalEvent: = "WethWithdrawalEvent"
Defined in types.ts:451
• Added: = "ADDED"
Defined in types.ts:509
• Cancelled: = "CANCELLED"
Defined in types.ts:512
• Expired: = "EXPIRED"
Defined in types.ts:513
• FillabilityIncreased: = "FILLABILITY_INCREASED"
Defined in types.ts:516
• Filled: = "FILLED"
Defined in types.ts:510
• FullyFilled: = "FULLY_FILLED"
Defined in types.ts:511
• Invalid: = "INVALID"
Defined in types.ts:508
• StoppedWatching: = "STOPPED_WATCHING"
Defined in types.ts:517
• Unexpired: = "UNEXPIRED"
Defined in types.ts:514
• Unfunded: = "UNFUNDED"
Defined in types.ts:515
A set of categories for rejected orders.
• CoordinatorError: = "COORDINATOR_ERROR"
Defined in types.ts:600
• MeshError: = "MESH_ERROR"
Defined in types.ts:598
• MeshValidation: = "MESH_VALIDATION"
Defined in types.ts:599
• ZeroExValidation: = "ZEROEX_VALIDATION"
Defined in types.ts:597
• Debug: = 5
Defined in types.ts:209
• Error: = 2
Defined in types.ts:206
• Fatal: = 1
Defined in types.ts:205
• Info: = 4
Defined in types.ts:208
• Panic: = 0
Defined in types.ts:204
• Trace: = 6
Defined in types.ts:210
• Warn: = 3
Defined in types.ts:207
Info for any orders that were accepted.
AcceptedOrderInfo
• fillableTakerAssetAmount: BigNumber
Defined in types.ts:578
• isNew: boolean
Defined in types.ts:579
• orderHash: string
Defined in types.ts:576
• signedOrder: SignedOrder
Defined in types.ts:577
A set of configuration options for Mesh.
Config
Optional
blockPollingIntervalSeconds• blockPollingIntervalSeconds? : undefined | number
Defined in types.ts:116
Optional
bootstrapList• bootstrapList? : string[]
Defined in types.ts:109
Optional
customContractAddresses• customContractAddresses? : ContractAddresses
Defined in types.ts:160
Optional
customOrderFilter• customOrderFilter? : JsonSchema
Defined in types.ts:185
Optional
enableEthereumRPCRateLimiting• enableEthereumRPCRateLimiting? : undefined | false | true
Defined in types.ts:133
• ethereumChainID: number
Defined in types.ts:101
Optional
ethereumRPCMaxContentLength• ethereumRPCMaxContentLength? : undefined | number
Defined in types.ts:125
Optional
ethereumRPCMaxRequestsPer24HrUTC• ethereumRPCMaxRequestsPer24HrUTC? : undefined | number
Defined in types.ts:138
Optional
ethereumRPCMaxRequestsPerSecond• ethereumRPCMaxRequestsPerSecond? : undefined | number
Defined in types.ts:144
Optional
ethereumRPCURL• ethereumRPCURL? : undefined | string
Defined in types.ts:98
Optional
maxOrdersInStorage• maxOrdersInStorage? : undefined | number
Defined in types.ts:165
Optional
useBootstrapList• useBootstrapList? : undefined | false | true
Defined in types.ts:104
Optional
verbosity• verbosity? : Verbosity
Defined in types.ts:95
Optional
web3Provider• web3Provider? : SupportedProvider
Defined in types.ts:188
ContractAddresses
Optional
coordinator• coordinator? : undefined | string
Defined in types.ts:197
Optional
coordinatorRegistry• coordinatorRegistry? : undefined | string
Defined in types.ts:198
• devUtils: string
Defined in types.ts:193
• erc1155Proxy: string
Defined in types.ts:196
• erc20Proxy: string
Defined in types.ts:194
• erc721Proxy: string
Defined in types.ts:195
• exchange: string
Defined in types.ts:192
Optional
weth9• weth9? : undefined | string
Defined in types.ts:199
Optional
zrxToken• zrxToken? : undefined | string
Defined in types.ts:200
ContractEvent
• address: string
Defined in types.ts:490
• blockHash: string
Defined in types.ts:485
• isRemoved: boolean
Defined in types.ts:489
• kind: ContractEventKind
Defined in types.ts:491
• logIndex: number
Defined in types.ts:488
• parameters: ContractEventParameters
Defined in types.ts:492
• txHash: string
Defined in types.ts:486
• txIndex: number
Defined in types.ts:487
ERC1155ApprovalForAllEvent
• approved: boolean
Defined in types.ts:360
• operator: string
Defined in types.ts:359
• owner: string
Defined in types.ts:358
ERC1155TransferBatchEvent
• from: string
Defined in types.ts:343
• ids: BigNumber[]
Defined in types.ts:345
• operator: string
Defined in types.ts:342
• to: string
Defined in types.ts:344
• values: BigNumber[]
Defined in types.ts:346
ERC1155TransferSingleEvent
• from: string
Defined in types.ts:327
• id: BigNumber
Defined in types.ts:329
• operator: string
Defined in types.ts:326
• to: string
Defined in types.ts:328
• value: BigNumber
Defined in types.ts:330
ERC20ApprovalEvent
• owner: string
Defined in types.ts:284
• spender: string
Defined in types.ts:285
• value: BigNumber
Defined in types.ts:286
ERC20TransferEvent
• from: string
Defined in types.ts:272
• to: string
Defined in types.ts:273
• value: BigNumber
Defined in types.ts:274
ERC721ApprovalEvent
• approved: string
Defined in types.ts:309
• owner: string
Defined in types.ts:308
• tokenId: BigNumber
Defined in types.ts:310
ERC721ApprovalForAllEvent
• approved: boolean
Defined in types.ts:322
• operator: string
Defined in types.ts:321
• owner: string
Defined in types.ts:320
ERC721TransferEvent
• from: string
Defined in types.ts:296
• to: string
Defined in types.ts:297
• tokenId: BigNumber
Defined in types.ts:298
ExchangeCancelEvent
• feeRecipientAddress: string
Defined in types.ts:400
• makerAddress: string
Defined in types.ts:398
• makerAssetData: string
Defined in types.ts:402
• orderHash: string
Defined in types.ts:401
• senderAddress: string
Defined in types.ts:399
• takerAssetData: string
Defined in types.ts:403
ExchangeCancelUpToEvent
• makerAddress: string
Defined in types.ts:407
• orderEpoch: BigNumber
Defined in types.ts:409
• orderSenderAddress: string
Defined in types.ts:408
ExchangeFillEvent
• feeRecipientAddress: string
Defined in types.ts:367
• makerAddress: string
Defined in types.ts:364
• makerAssetData: string
Defined in types.ts:374
• makerAssetFilledAmount: BigNumber
Defined in types.ts:368
• makerFeeAssetData: string
Defined in types.ts:376
• makerFeePaid: BigNumber
Defined in types.ts:370
• orderHash: string
Defined in types.ts:373
• protocolFeePaid: BigNumber
Defined in types.ts:372
• senderAddress: string
Defined in types.ts:366
• takerAddress: string
Defined in types.ts:365
• takerAssetData: string
Defined in types.ts:375
• takerAssetFilledAmount: BigNumber
Defined in types.ts:369
• takerFeeAssetData: string
Defined in types.ts:377
• takerFeePaid: BigNumber
Defined in types.ts:371
GetOrdersResponse
• ordersInfos: OrderInfo[]
Defined in types.ts:18
• snapshotID: string
Defined in types.ts:16
• snapshotTimestamp: number
Defined in types.ts:17
An interface for JSON schema types, which are used for custom order filters.
JsonSchema
Optional
$ref• $ref? : undefined | string
Defined in types.ts:39
Optional
$schema• $schema? : undefined | string
Defined in types.ts:38
Optional
additionalItems• additionalItems? : boolean | JsonSchema
Defined in types.ts:50
Optional
additionalProperties• additionalProperties? : boolean | JsonSchema
Defined in types.ts:58
Optional
allOf• allOf? : JsonSchema[]
Defined in types.ts:80
Optional
anyOf• anyOf? : JsonSchema[]
Defined in types.ts:81
Optional
const• const? : any
Defined in types.ts:77
Optional
definitions• definitions? : undefined | object
Defined in types.ts:59
Optional
dependencies• dependencies? : undefined | object
Defined in types.ts:68
Optional
description• description? : undefined | string
Defined in types.ts:41
Optional
enum• enum? : any[]
Defined in types.ts:71
Optional
exclusiveMaximum• exclusiveMaximum? : undefined | false | true
Defined in types.ts:44
Optional
exclusiveMinimum• exclusiveMinimum? : undefined | false | true
Defined in types.ts:46
Optional
format• format? : undefined | string
Defined in types.ts:79
Optional
id• id? : undefined | string
Defined in types.ts:37
Optional
items• items? : JsonSchema | JsonSchema[]
Defined in types.ts:51
Optional
maxItems• maxItems? : undefined | number
Defined in types.ts:52
Optional
maxLength• maxLength? : undefined | number
Defined in types.ts:47
Optional
maxProperties• maxProperties? : undefined | number
Defined in types.ts:55
Optional
maximum• maximum? : undefined | number
Defined in types.ts:43
Optional
minItems• minItems? : undefined | number
Defined in types.ts:53
Optional
minLength• minLength? : undefined | number
Defined in types.ts:48
Optional
minProperties• minProperties? : undefined | number
Defined in types.ts:56
Optional
minimum• minimum? : undefined | number
Defined in types.ts:45
Optional
multipleOf• multipleOf? : undefined | number
Defined in types.ts:42
Optional
not• not? : JsonSchema
Defined in types.ts:83
Optional
oneOf• oneOf? : JsonSchema[]
Defined in types.ts:82
Optional
pattern• pattern? : string | RegExp
Defined in types.ts:49
Optional
patternProperties• patternProperties? : undefined | object
Defined in types.ts:65
Optional
properties• properties? : undefined | object
Defined in types.ts:62
Optional
required• required? : string[]
Defined in types.ts:57
Optional
title• title? : undefined | string
Defined in types.ts:40
Optional
type• type? : string | string[]
Defined in types.ts:78
Optional
uniqueItems• uniqueItems? : undefined | false | true
Defined in types.ts:54
LatestBlock
• hash: string
Defined in types.ts:613
• number: number
Defined in types.ts:612
Order events are fired by Mesh whenever an order is added, canceled, expired, or filled.
OrderEvent
• contractEvents: ContractEvent[]
Defined in types.ts:539
• endState: OrderEventEndState
Defined in types.ts:537
• fillableTakerAssetAmount: BigNumber
Defined in types.ts:538
• orderHash: string
Defined in types.ts:535
• signedOrder: SignedOrder
Defined in types.ts:536
• timestampMs: number
Defined in types.ts:534
OrderInfo
• fillableTakerAssetAmount: BigNumber
Defined in types.ts:30
• orderHash: string
Defined in types.ts:28
• signedOrder: SignedOrder
Defined in types.ts:29
Info for any orders that were rejected, including the reason they were rejected.
RejectedOrderInfo
• kind: RejectedOrderKind
Defined in types.ts:589
• orderHash: string
Defined in types.ts:587
• signedOrder: SignedOrder
Defined in types.ts:588
• status: RejectedOrderStatus
Defined in types.ts:590
Provides more information about why an order was rejected.
RejectedOrderStatus
• code: string
Defined in types.ts:607
• message: string
Defined in types.ts:608
Stats
• ethRPCRateLimitExpiredRequests: number
Defined in types.ts:649
• ethRPCRequestsSentInCurrentUTCDay: number
Defined in types.ts:648
• ethereumChainID: number
Defined in types.ts:640
• latestBlock: LatestBlock
Defined in types.ts:641
• maxExpirationTime: BigNumber
Defined in types.ts:646
• numOrders: number
Defined in types.ts:643
• numOrdersIncludingRemoved: number
Defined in types.ts:644
• numPeers: number
Defined in types.ts:642
• numPinnedOrders: number
Defined in types.ts:645
• peerID: string
Defined in types.ts:639
• pubSubTopic: string
Defined in types.ts:636
• rendezvous: string
Defined in types.ts:637
• secondaryRendezvous: string[]
Defined in types.ts:638
• startOfCurrentUTCDay: Date
Defined in types.ts:647
• version: string
Defined in types.ts:635
Indicates which orders where accepted, which were rejected, and why.
ValidationResults
• accepted: AcceptedOrderInfo[]
Defined in types.ts:568
• rejected: RejectedOrderInfo[]
Defined in types.ts:569
WethDepositEvent
• owner: string
Defined in types.ts:429
• value: BigNumber
Defined in types.ts:430
WethWithdrawalEvent
• owner: string
Defined in types.ts:419
• value: BigNumber
Defined in types.ts:420
Name
Type
Description
config
Configuration options for Mesh
Name
Type
Default
Description
orders
SignedOrder[]
-
An array of orders to add.
pinned
boolean
true
Whether or not the orders should be pinned. Pinned orders will not be affected by any DDoS prevention or incentive mechanisms and will always stay in storage until they are no longer fillable.
Name
Type
Default
Description
perPage
number
200
number of signedOrders to fetch per paginated request
Name
Type
Description
page
number
Page index at which to retrieve orders
perPage
number
Number of signedOrders to fetch per paginated request
snapshotID?
undefined | string
The DB snapshot at which to fetch orders. If omitted, a new snapshot is created
Name
Type
err
Error
Name
Type
events