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 index.ts:641
Instantiates a new Mesh instance.
Parameters:
Returns: Mesh
An instance of Mesh
▸ addOrdersAsync(orders
: SignedOrder[], pinned
: boolean): Promise‹ValidationResults›
Defined in index.ts:791
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 index.ts:720
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 index.ts:762
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 index.ts:703
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 index.ts:661
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 index.ts:676
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 index.ts:687
Starts the Mesh node in the background. Mesh will automatically find peers in the network and begin receiving orders from them.
Returns: Promise‹void›
• Added: = "ADDED"
Defined in index.ts:504
• Cancelled: = "CANCELLED"
Defined in index.ts:507
• Expired: = "EXPIRED"
Defined in index.ts:508
• FillabilityIncreased: = "FILLABILITY_INCREASED"
Defined in index.ts:511
• Filled: = "FILLED"
Defined in index.ts:505
• FullyFilled: = "FULLY_FILLED"
Defined in index.ts:506
• Invalid: = "INVALID"
Defined in index.ts:503
• StoppedWatching: = "STOPPED_WATCHING"
Defined in index.ts:512
• Unexpired: = "UNEXPIRED"
Defined in index.ts:509
• Unfunded: = "UNFUNDED"
Defined in index.ts:510
A set of categories for rejected orders.
• CoordinatorError: = "COORDINATOR_ERROR"
Defined in index.ts:595
• MeshError: = "MESH_ERROR"
Defined in index.ts:593
• MeshValidation: = "MESH_VALIDATION"
Defined in index.ts:594
• ZeroExValidation: = "ZEROEX_VALIDATION"
Defined in index.ts:592
• Debug: = 5
Defined in index.ts:212
• Error: = 2
Defined in index.ts:209
• Fatal: = 1
Defined in index.ts:208
• Info: = 4
Defined in index.ts:211
• Panic: = 0
Defined in index.ts:207
• Trace: = 6
Defined in index.ts:213
• Warn: = 3
Defined in index.ts:210
Info for any orders that were accepted.
AcceptedOrderInfo
• fillableTakerAssetAmount: BigNumber
Defined in index.ts:573
• isNew: boolean
Defined in index.ts:574
• orderHash: string
Defined in index.ts:571
• signedOrder: SignedOrder
Defined in index.ts:572
A set of configuration options for Mesh.
Config
Optional
blockPollingIntervalSeconds• blockPollingIntervalSeconds? : undefined | number
Defined in index.ts:79
Optional
bootstrapList• bootstrapList? : string[]
Defined in index.ts:72
Optional
customContractAddresses• customContractAddresses? : ContractAddresses
Defined in index.ts:123
Optional
enableEthereumRPCRateLimiting• enableEthereumRPCRateLimiting? : undefined | false | true
Defined in index.ts:96
• ethereumChainID: number
Defined in index.ts:64
Optional
ethereumRPCMaxContentLength• ethereumRPCMaxContentLength? : undefined | number
Defined in index.ts:88
Optional
ethereumRPCMaxRequestsPer24HrUTC• ethereumRPCMaxRequestsPer24HrUTC? : undefined | number
Defined in index.ts:101
Optional
ethereumRPCMaxRequestsPerSecond• ethereumRPCMaxRequestsPerSecond? : undefined | number
Defined in index.ts:107
• ethereumRPCURL: string
Defined in index.ts:61
Optional
maxOrdersInStorage• maxOrdersInStorage? : undefined | number
Defined in index.ts:128
Optional
useBootstrapList• useBootstrapList? : undefined | false | true
Defined in index.ts:67
Optional
verbosity• verbosity? : Verbosity
Defined in index.ts:58
ContractAddresses
Optional
coordinator• coordinator? : undefined | string
Defined in index.ts:137
Optional
coordinatorRegistry• coordinatorRegistry? : undefined | string
Defined in index.ts:138
• devUtils: string
Defined in index.ts:133
• erc1155Proxy: string
Defined in index.ts:136
• erc20Proxy: string
Defined in index.ts:134
• erc721Proxy: string
Defined in index.ts:135
• exchange: string
Defined in index.ts:132
Optional
weth9• weth9? : undefined | string
Defined in index.ts:139
Optional
zrxToken• zrxToken? : undefined | string
Defined in index.ts:140
ContractEvent
• address: string
Defined in index.ts:485
• blockHash: string
Defined in index.ts:480
• isRemoved: string
Defined in index.ts:484
• kind: ContractEventKind
Defined in index.ts:486
• logIndex: number
Defined in index.ts:483
• parameters: ContractEventParameters
Defined in index.ts:487
• txHash: string
Defined in index.ts:481
• txIndex: number
Defined in index.ts:482
ERC1155ApprovalForAllEvent
• approved: boolean
Defined in index.ts:361
• operator: string
Defined in index.ts:360
• owner: string
Defined in index.ts:359
ERC1155TransferBatchEvent
• from: string
Defined in index.ts:344
• ids: BigNumber[]
Defined in index.ts:346
• operator: string
Defined in index.ts:343
• to: string
Defined in index.ts:345
• values: BigNumber[]
Defined in index.ts:347
ERC1155TransferSingleEvent
• from: string
Defined in index.ts:328
• id: BigNumber
Defined in index.ts:330
• operator: string
Defined in index.ts:327
• to: string
Defined in index.ts:329
• value: BigNumber
Defined in index.ts:331
ERC20ApprovalEvent
• owner: string
Defined in index.ts:285
• spender: string
Defined in index.ts:286
• value: BigNumber
Defined in index.ts:287
ERC20TransferEvent
• from: string
Defined in index.ts:273
• to: string
Defined in index.ts:274
• value: BigNumber
Defined in index.ts:275
ERC721ApprovalEvent
• approved: string
Defined in index.ts:310
• owner: string
Defined in index.ts:309
• tokenId: BigNumber
Defined in index.ts:311
ERC721ApprovalForAllEvent
• approved: boolean
Defined in index.ts:323
• operator: string
Defined in index.ts:322
• owner: string
Defined in index.ts:321
ERC721TransferEvent
• from: string
Defined in index.ts:297
• to: string
Defined in index.ts:298
• tokenId: BigNumber
Defined in index.ts:299
ExchangeCancelEvent
• feeRecipientAddress: string
Defined in index.ts:395
• makerAddress: string
Defined in index.ts:393
• makerAssetData: string
Defined in index.ts:397
• orderHash: string
Defined in index.ts:396
• senderAddress: string
Defined in index.ts:394
• takerAssetData: string
Defined in index.ts:398
ExchangeCancelUpToEvent
• makerAddress: string
Defined in index.ts:402
• orderEpoch: BigNumber
Defined in index.ts:404
• senderAddress: string
Defined in index.ts:403
ExchangeFillEvent
• feeRecipientAddress: string
Defined in index.ts:368
• makerAddress: string
Defined in index.ts:365
• makerAssetData: string
Defined in index.ts:374
• makerAssetFilledAmount: BigNumber
Defined in index.ts:369
• makerFeePaid: BigNumber
Defined in index.ts:371
• orderHash: string
Defined in index.ts:373
• senderAddress: string
Defined in index.ts:367
• takerAddress: string
Defined in index.ts:366
• takerAssetData: string
Defined in index.ts:375
• takerAssetFilledAmount: BigNumber
Defined in index.ts:370
• takerFeePaid: BigNumber
Defined in index.ts:372
GetOrdersResponse
• ordersInfos: OrderInfo[]
Defined in index.ts:203
• snapshotID: string
Defined in index.ts:201
• snapshotTimestamp: number
Defined in index.ts:202
LatestBlock
• hash: string
Defined in index.ts:145
• number: number
Defined in index.ts:144
Order events are fired by Mesh whenever an order is added, canceled, expired, or filled.
OrderEvent
• contractEvents: ContractEvent[]
Defined in index.ts:534
• endState: OrderEventEndState
Defined in index.ts:532
• fillableTakerAssetAmount: BigNumber
Defined in index.ts:533
• orderHash: string
Defined in index.ts:530
• signedOrder: SignedOrder
Defined in index.ts:531
• timestampMs: number
Defined in index.ts:529
OrderInfo
• fillableTakerAssetAmount: BigNumber
Defined in index.ts:191
• orderHash: string
Defined in index.ts:189
• signedOrder: SignedOrder
Defined in index.ts:190
Info for any orders that were rejected, including the reason they were rejected.
RejectedOrderInfo
• kind: RejectedOrderKind
Defined in index.ts:584
• orderHash: string
Defined in index.ts:582
• signedOrder: SignedOrder
Defined in index.ts:583
• status: RejectedOrderStatus
Defined in index.ts:585
Provides more information about why an order was rejected.
RejectedOrderStatus
• code: string
Defined in index.ts:602
• message: string
Defined in index.ts:603
Stats
• ethRPCRateLimitExpiredRequests: number
Defined in index.ts:179
• ethRPCRequestsSentInCurrentUTCDay: number
Defined in index.ts:178
• ethereumChainID: number
Defined in index.ts:170
• latestBlock: LatestBlock
Defined in index.ts:171
• maxExpirationTime: BigNumber
Defined in index.ts:176
• numOrders: number
Defined in index.ts:173
• numOrdersIncludingRemoved: number
Defined in index.ts:174
• numPeers: number
Defined in index.ts:172
• numPinnedOrders: number
Defined in index.ts:175
• peerID: string
Defined in index.ts:169
• pubSubTopic: string
Defined in index.ts:167
• rendezvous: string
Defined in index.ts:168
• startOfCurrentUTCDay: Date
Defined in index.ts:177
• version: string
Defined in index.ts:166
Indicates which orders where accepted, which were rejected, and why.
ValidationResults
• accepted: AcceptedOrderInfo[]
Defined in index.ts:563
• rejected: RejectedOrderInfo[]
Defined in index.ts:564
WethDepositEvent
• owner: string
Defined in index.ts:424
• value: BigNumber
Defined in index.ts:425
WethWithdrawalEvent
• owner: string
Defined in index.ts:414
• value: BigNumber
Defined in index.ts:415