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:142
Instantiates a new Mesh instance.
Parameters:
Returns: Mesh
An instance of Mesh
▸ addOrdersAsync(orders
: SignedOrder[], pinned
: boolean): Promise‹ValidationResults›
Defined in mesh.ts:292
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:221
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:263
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:204
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:162
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:177
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:188
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:468
• ERC1155TransferBatchEvent: = "ERC1155TransferBatchEvent"
Defined in types.ts:470
• ERC1155TransferSingleEvent: = "ERC1155TransferSingleEvent"
Defined in types.ts:469
• ERC20ApprovalEvent: = "ERC20ApprovalEvent"
Defined in types.ts:464
• ERC20TransferEvent: = "ERC20TransferEvent"
Defined in types.ts:463
• ERC721ApprovalEvent: = "ERC721ApprovalEvent"
Defined in types.ts:466
• ERC721ApprovalForAllEvent: = "ERC721ApprovalForAllEvent"
Defined in types.ts:467
• ERC721TransferEvent: = "ERC721TransferEvent"
Defined in types.ts:465
• ExchangeCancelEvent: = "ExchangeCancelEvent"
Defined in types.ts:472
• ExchangeCancelUpToEvent: = "ExchangeCancelUpToEvent"
Defined in types.ts:473
• ExchangeFillEvent: = "ExchangeFillEvent"
Defined in types.ts:471
• WethDepositEvent: = "WethDepositEvent"
Defined in types.ts:474
• WethWithdrawalEvent: = "WethWithdrawalEvent"
Defined in types.ts:475
• Added: = "ADDED"
Defined in types.ts:538
• Cancelled: = "CANCELLED"
Defined in types.ts:541
• Expired: = "EXPIRED"
Defined in types.ts:542
• FillabilityIncreased: = "FILLABILITY_INCREASED"
Defined in types.ts:545
• Filled: = "FILLED"
Defined in types.ts:539
• FullyFilled: = "FULLY_FILLED"
Defined in types.ts:540
• Invalid: = "INVALID"
Defined in types.ts:537
• StoppedWatching: = "STOPPED_WATCHING"
Defined in types.ts:546
• Unexpired: = "UNEXPIRED"
Defined in types.ts:543
• Unfunded: = "UNFUNDED"
Defined in types.ts:544
A set of categories for rejected orders.
• CoordinatorError: = "COORDINATOR_ERROR"
Defined in types.ts:630
• MeshError: = "MESH_ERROR"
Defined in types.ts:628
• MeshValidation: = "MESH_VALIDATION"
Defined in types.ts:629
• ZeroExValidation: = "ZEROEX_VALIDATION"
Defined in types.ts:627
• Debug: = 5
Defined in types.ts:211
• Error: = 2
Defined in types.ts:208
• Fatal: = 1
Defined in types.ts:207
• Info: = 4
Defined in types.ts:210
• Panic: = 0
Defined in types.ts:206
• Trace: = 6
Defined in types.ts:212
• Warn: = 3
Defined in types.ts:209
SchemaValidationResult
• errors: string[]
Defined in schema_validator.ts:11
Optional
fatal• fatal? : undefined | string
Defined in schema_validator.ts:12
• success: boolean
Defined in schema_validator.ts:10
SchemaValidator
• messageValidator: function
Defined in schema_validator.ts:17
Type declaration:
▸ (input
: string): SchemaValidationResult
Parameters:
• orderValidator: function
Defined in schema_validator.ts:16
Type declaration:
▸ (input
: string): SchemaValidationResult
Parameters:
Info for any orders that were accepted.
AcceptedOrderInfo
• fillableTakerAssetAmount: BigNumber
Defined in types.ts:608
• isNew: boolean
Defined in types.ts:609
• orderHash: string
Defined in types.ts:606
• signedOrder: SignedOrder
Defined in types.ts:607
A set of configuration options for Mesh.
Config
Optional
blockPollingIntervalSeconds• blockPollingIntervalSeconds? : undefined | number
Defined in types.ts:118
Optional
bootstrapList• bootstrapList? : string[]
Defined in types.ts:111
Optional
customContractAddresses• customContractAddresses? : ContractAddresses
Defined in types.ts:162
Optional
customOrderFilter• customOrderFilter? : JsonSchema
Defined in types.ts:187
Optional
enableEthereumRPCRateLimiting• enableEthereumRPCRateLimiting? : undefined | false | true
Defined in types.ts:135
• ethereumChainID: number
Defined in types.ts:103
Optional
ethereumRPCMaxContentLength• ethereumRPCMaxContentLength? : undefined | number
Defined in types.ts:127
Optional
ethereumRPCMaxRequestsPer24HrUTC• ethereumRPCMaxRequestsPer24HrUTC? : undefined | number
Defined in types.ts:140
Optional
ethereumRPCMaxRequestsPerSecond• ethereumRPCMaxRequestsPerSecond? : undefined | number
Defined in types.ts:146
Optional
ethereumRPCURL• ethereumRPCURL? : undefined | string
Defined in types.ts:100
Optional
maxOrdersInStorage• maxOrdersInStorage? : undefined | number
Defined in types.ts:167
Optional
useBootstrapList• useBootstrapList? : undefined | false | true
Defined in types.ts:106
Optional
verbosity• verbosity? : Verbosity
Defined in types.ts:97
Optional
web3Provider• web3Provider? : SupportedProvider
Defined in types.ts:190
ContractAddresses
Optional
coordinator• coordinator? : undefined | string
Defined in types.ts:199
Optional
coordinatorRegistry• coordinatorRegistry? : undefined | string
Defined in types.ts:200
• devUtils: string
Defined in types.ts:195
• erc1155Proxy: string
Defined in types.ts:198
• erc20Proxy: string
Defined in types.ts:196
• erc721Proxy: string
Defined in types.ts:197
• exchange: string
Defined in types.ts:194
Optional
weth9• weth9? : undefined | string
Defined in types.ts:201
Optional
zrxToken• zrxToken? : undefined | string
Defined in types.ts:202
ContractEvent
• address: string
Defined in types.ts:516
• blockHash: string
Defined in types.ts:511
• isRemoved: boolean
Defined in types.ts:515
• kind: ContractEventKind
Defined in types.ts:517
• logIndex: number
Defined in types.ts:514
• parameters: ContractEventParameters
Defined in types.ts:518
• txHash: string
Defined in types.ts:512
• txIndex: number
Defined in types.ts:513
ERC1155ApprovalForAllEvent
• approved: boolean
Defined in types.ts:380
• operator: string
Defined in types.ts:379
• owner: string
Defined in types.ts:378
ERC1155TransferBatchEvent
• from: string
Defined in types.ts:362
• ids: BigNumber[]
Defined in types.ts:364
• operator: string
Defined in types.ts:361
• to: string
Defined in types.ts:363
• values: BigNumber[]
Defined in types.ts:365
ERC1155TransferSingleEvent
• from: string
Defined in types.ts:345
• id: BigNumber
Defined in types.ts:347
• operator: string
Defined in types.ts:344
• to: string
Defined in types.ts:346
• value: BigNumber
Defined in types.ts:348
ERC20ApprovalEvent
• owner: string
Defined in types.ts:299
• spender: string
Defined in types.ts:300
• value: BigNumber
Defined in types.ts:301
ERC20TransferEvent
• from: string
Defined in types.ts:286
• to: string
Defined in types.ts:287
• value: BigNumber
Defined in types.ts:288
ERC721ApprovalEvent
• approved: string
Defined in types.ts:326
• owner: string
Defined in types.ts:325
• tokenId: BigNumber
Defined in types.ts:327
ERC721ApprovalForAllEvent
• approved: boolean
Defined in types.ts:340
• operator: string
Defined in types.ts:339
• owner: string
Defined in types.ts:338
ERC721TransferEvent
• from: string
Defined in types.ts:312
• to: string
Defined in types.ts:313
• tokenId: BigNumber
Defined in types.ts:314
ExchangeCancelEvent
• feeRecipientAddress: string
Defined in types.ts:421
• makerAddress: string
Defined in types.ts:419
• makerAssetData: string
Defined in types.ts:423
• orderHash: string
Defined in types.ts:422
• senderAddress: string
Defined in types.ts:420
• takerAssetData: string
Defined in types.ts:424
ExchangeCancelUpToEvent
• makerAddress: string
Defined in types.ts:428
• orderEpoch: BigNumber
Defined in types.ts:430
• orderSenderAddress: string
Defined in types.ts:429
ExchangeFillEvent
• feeRecipientAddress: string
Defined in types.ts:387
• makerAddress: string
Defined in types.ts:384
• makerAssetData: string
Defined in types.ts:394
• makerAssetFilledAmount: BigNumber
Defined in types.ts:388
• makerFeeAssetData: string
Defined in types.ts:396
• makerFeePaid: BigNumber
Defined in types.ts:390
• orderHash: string
Defined in types.ts:393
• protocolFeePaid: BigNumber
Defined in types.ts:392
• senderAddress: string
Defined in types.ts:386
• takerAddress: string
Defined in types.ts:385
• takerAssetData: string
Defined in types.ts:395
• takerAssetFilledAmount: BigNumber
Defined in types.ts:389
• takerFeeAssetData: string
Defined in types.ts:397
• takerFeePaid: BigNumber
Defined in types.ts:391
GetOrdersResponse
• ordersInfos: OrderInfo[]
Defined in types.ts:19
• snapshotID: string
Defined in types.ts:17
• snapshotTimestamp: number
Defined in types.ts:18
An interface for JSON schema types, which are used for custom order filters.
JsonSchema
Optional
$ref• $ref? : undefined | string
Defined in types.ts:41
Optional
$schema• $schema? : undefined | string
Defined in types.ts:40
Optional
additionalItems• additionalItems? : boolean | JsonSchema
Defined in types.ts:52
Optional
additionalProperties• additionalProperties? : boolean | JsonSchema
Defined in types.ts:60
Optional
allOf• allOf? : JsonSchema[]
Defined in types.ts:82
Optional
anyOf• anyOf? : JsonSchema[]
Defined in types.ts:83
Optional
const• const? : any
Defined in types.ts:79
Optional
definitions• definitions? : undefined | object
Defined in types.ts:61
Optional
dependencies• dependencies? : undefined | object
Defined in types.ts:70
Optional
description• description? : undefined | string
Defined in types.ts:43
Optional
enum• enum? : any[]
Defined in types.ts:73
Optional
exclusiveMaximum• exclusiveMaximum? : undefined | false | true
Defined in types.ts:46
Optional
exclusiveMinimum• exclusiveMinimum? : undefined | false | true
Defined in types.ts:48
Optional
format• format? : undefined | string
Defined in types.ts:81
Optional
id• id? : undefined | string
Defined in types.ts:39
Optional
items• items? : JsonSchema | JsonSchema[]
Defined in types.ts:53
Optional
maxItems• maxItems? : undefined | number
Defined in types.ts:54
Optional
maxLength• maxLength? : undefined | number
Defined in types.ts:49
Optional
maxProperties• maxProperties? : undefined | number
Defined in types.ts:57
Optional
maximum• maximum? : undefined | number
Defined in types.ts:45
Optional
minItems• minItems? : undefined | number
Defined in types.ts:55
Optional
minLength• minLength? : undefined | number
Defined in types.ts:50
Optional
minProperties• minProperties? : undefined | number
Defined in types.ts:58
Optional
minimum• minimum? : undefined | number
Defined in types.ts:47
Optional
multipleOf• multipleOf? : undefined | number
Defined in types.ts:44
Optional
not• not? : JsonSchema
Defined in types.ts:85
Optional
oneOf• oneOf? : JsonSchema[]
Defined in types.ts:84
Optional
pattern• pattern? : string | RegExp
Defined in types.ts:51
Optional
patternProperties• patternProperties? : undefined | object
Defined in types.ts:67
Optional
properties• properties? : undefined | object
Defined in types.ts:64
Optional
required• required? : string[]
Defined in types.ts:59
Optional
title• title? : undefined | string
Defined in types.ts:42
Optional
type• type? : string | string[]
Defined in types.ts:80
Optional
uniqueItems• uniqueItems? : undefined | false | true
Defined in types.ts:56
LatestBlock
• hash: string
Defined in types.ts:643
• number: number
Defined in types.ts:642
Order events are fired by Mesh whenever an order is added, canceled, expired, or filled.
OrderEvent
• contractEvents: ContractEvent[]
Defined in types.ts:569
• endState: OrderEventEndState
Defined in types.ts:567
• fillableTakerAssetAmount: BigNumber
Defined in types.ts:568
• orderHash: string
Defined in types.ts:565
• signedOrder: SignedOrder
Defined in types.ts:566
• timestampMs: number
Defined in types.ts:564
OrderInfo
• fillableTakerAssetAmount: BigNumber
Defined in types.ts:32
• orderHash: string
Defined in types.ts:30
• signedOrder: SignedOrder
Defined in types.ts:31
Info for any orders that were rejected, including the reason they were rejected.
RejectedOrderInfo
• kind: RejectedOrderKind
Defined in types.ts:619
• orderHash: string
Defined in types.ts:617
• signedOrder: SignedOrder
Defined in types.ts:618
• status: RejectedOrderStatus
Defined in types.ts:620
Provides more information about why an order was rejected.
RejectedOrderStatus
• code: string
Defined in types.ts:637
• message: string
Defined in types.ts:638
Stats
• ethRPCRateLimitExpiredRequests: number
Defined in types.ts:680
• ethRPCRequestsSentInCurrentUTCDay: number
Defined in types.ts:679
• ethereumChainID: number
Defined in types.ts:671
• latestBlock: LatestBlock
Defined in types.ts:672
• maxExpirationTime: BigNumber
Defined in types.ts:677
• numOrders: number
Defined in types.ts:674
• numOrdersIncludingRemoved: number
Defined in types.ts:675
• numPeers: number
Defined in types.ts:673
• numPinnedOrders: number
Defined in types.ts:676
• peerID: string
Defined in types.ts:670
• pubSubTopic: string
Defined in types.ts:667
• rendezvous: string
Defined in types.ts:668
• secondaryRendezvous: string[]
Defined in types.ts:669
• startOfCurrentUTCDay: Date
Defined in types.ts:678
• version: string
Defined in types.ts:666
Indicates which orders where accepted, which were rejected, and why.
ValidationResults
• accepted: AcceptedOrderInfo[]
Defined in types.ts:598
• rejected: RejectedOrderInfo[]
Defined in types.ts:599
WethDepositEvent
• owner: string
Defined in types.ts:452
• value: BigNumber
Defined in types.ts:453
WethWithdrawalEvent
• owner: string
Defined in types.ts:441
• value: BigNumber
Defined in types.ts:442
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
Name
Type
input
string
Name
Type
input
string