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:576
Instantiates a new Mesh instance.
Parameters:
Returns: Mesh
An instance of Mesh
▸ addOrdersAsync(orders
: SignedOrder[], pinned
: boolean): Promise‹ValidationResults›
Defined in index.ts:650
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.
▸ onError(handler
: function): void
Defined in index.ts:596
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:611
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:622
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:439
• Cancelled: = "CANCELLED"
Defined in index.ts:442
• Expired: = "EXPIRED"
Defined in index.ts:443
• FillabilityIncreased: = "FILLABILITY_INCREASED"
Defined in index.ts:446
• Filled: = "FILLED"
Defined in index.ts:440
• FullyFilled: = "FULLY_FILLED"
Defined in index.ts:441
• Invalid: = "INVALID"
Defined in index.ts:438
• StoppedWatching: = "STOPPED_WATCHING"
Defined in index.ts:447
• Unexpired: = "UNEXPIRED"
Defined in index.ts:444
• Unfunded: = "UNFUNDED"
Defined in index.ts:445
A set of categories for rejected orders.
• CoordinatorError: = "COORDINATOR_ERROR"
Defined in index.ts:530
• MeshError: = "MESH_ERROR"
Defined in index.ts:528
• MeshValidation: = "MESH_VALIDATION"
Defined in index.ts:529
• ZeroExValidation: = "ZEROEX_VALIDATION"
Defined in index.ts:527
• Debug: = 5
Defined in index.ts:149
• Error: = 2
Defined in index.ts:146
• Fatal: = 1
Defined in index.ts:145
• Info: = 4
Defined in index.ts:148
• Panic: = 0
Defined in index.ts:144
• Trace: = 6
Defined in index.ts:150
• Warn: = 3
Defined in index.ts:147
Info for any orders that were accepted.
AcceptedOrderInfo
• fillableTakerAssetAmount: BigNumber
Defined in index.ts:508
• isNew: boolean
Defined in index.ts:509
• orderHash: string
Defined in index.ts:506
• signedOrder: SignedOrder
Defined in index.ts:507
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:420
• blockHash: string
Defined in index.ts:415
• isRemoved: string
Defined in index.ts:419
• kind: ContractEventKind
Defined in index.ts:421
• logIndex: number
Defined in index.ts:418
• parameters: ContractEventParameters
Defined in index.ts:422
• txHash: string
Defined in index.ts:416
• txIndex: number
Defined in index.ts:417
ERC1155ApprovalForAllEvent
• approved: boolean
Defined in index.ts:296
• operator: string
Defined in index.ts:295
• owner: string
Defined in index.ts:294
ERC1155TransferBatchEvent
• from: string
Defined in index.ts:279
• ids: BigNumber[]
Defined in index.ts:281
• operator: string
Defined in index.ts:278
• to: string
Defined in index.ts:280
• values: BigNumber[]
Defined in index.ts:282
ERC1155TransferSingleEvent
• from: string
Defined in index.ts:263
• id: BigNumber
Defined in index.ts:265
• operator: string
Defined in index.ts:262
• to: string
Defined in index.ts:264
• value: BigNumber
Defined in index.ts:266
ERC20ApprovalEvent
• owner: string
Defined in index.ts:220
• spender: string
Defined in index.ts:221
• value: BigNumber
Defined in index.ts:222
ERC20TransferEvent
• from: string
Defined in index.ts:208
• to: string
Defined in index.ts:209
• value: BigNumber
Defined in index.ts:210
ERC721ApprovalEvent
• approved: string
Defined in index.ts:245
• owner: string
Defined in index.ts:244
• tokenId: BigNumber
Defined in index.ts:246
ERC721ApprovalForAllEvent
• approved: boolean
Defined in index.ts:258
• operator: string
Defined in index.ts:257
• owner: string
Defined in index.ts:256
ERC721TransferEvent
• from: string
Defined in index.ts:232
• to: string
Defined in index.ts:233
• tokenId: BigNumber
Defined in index.ts:234
ExchangeCancelEvent
• feeRecipientAddress: string
Defined in index.ts:330
• makerAddress: string
Defined in index.ts:328
• makerAssetData: string
Defined in index.ts:332
• orderHash: string
Defined in index.ts:331
• senderAddress: string
Defined in index.ts:329
• takerAssetData: string
Defined in index.ts:333
ExchangeCancelUpToEvent
• makerAddress: string
Defined in index.ts:337
• orderEpoch: BigNumber
Defined in index.ts:339
• senderAddress: string
Defined in index.ts:338
ExchangeFillEvent
• feeRecipientAddress: string
Defined in index.ts:303
• makerAddress: string
Defined in index.ts:300
• makerAssetData: string
Defined in index.ts:309
• makerAssetFilledAmount: BigNumber
Defined in index.ts:304
• makerFeePaid: BigNumber
Defined in index.ts:306
• orderHash: string
Defined in index.ts:308
• senderAddress: string
Defined in index.ts:302
• takerAddress: string
Defined in index.ts:301
• takerAssetData: string
Defined in index.ts:310
• takerAssetFilledAmount: BigNumber
Defined in index.ts:305
• takerFeePaid: BigNumber
Defined in index.ts:307
Order events are fired by Mesh whenever an order is added, canceled, expired, or filled.
OrderEvent
• contractEvents: ContractEvent[]
Defined in index.ts:469
• endState: OrderEventEndState
Defined in index.ts:467
• fillableTakerAssetAmount: BigNumber
Defined in index.ts:468
• orderHash: string
Defined in index.ts:465
• signedOrder: SignedOrder
Defined in index.ts:466
• timestampMs: number
Defined in index.ts:464
Info for any orders that were rejected, including the reason they were rejected.
RejectedOrderInfo
• kind: RejectedOrderKind
Defined in index.ts:519
• orderHash: string
Defined in index.ts:517
• signedOrder: SignedOrder
Defined in index.ts:518
• status: RejectedOrderStatus
Defined in index.ts:520
Provides more information about why an order was rejected.
RejectedOrderStatus
• code: string
Defined in index.ts:537
• message: string
Defined in index.ts:538
Indicates which orders where accepted, which were rejected, and why.
ValidationResults
• accepted: AcceptedOrderInfo[]
Defined in index.ts:498
• rejected: RejectedOrderInfo[]
Defined in index.ts:499
WethDepositEvent
• owner: string
Defined in index.ts:359
• value: BigNumber
Defined in index.ts:360
WethWithdrawalEvent
• owner: string
Defined in index.ts:349
• value: BigNumber
Defined in index.ts:350
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
err
Error
Name
Type
events