Skip to content

Commit 37678d2

Browse files
committed
update docs for mocknetworkprovider
1 parent d9c5cd8 commit 37678d2

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

website/docs/sdk/other-network-providers.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@ The CashScript SDK needs to connect to the BCH network to perform certain operat
66

77
## MockNetworkProvider
88
```ts
9-
new MockNetworkProvider(options?: { updateUtxoSet: boolean })
9+
new MockNetworkProvider(options?: MockNetworkProviderOptions)
1010
```
1111

1212
The `MockNetworkProvider` is a special network provider that allows you to evaluate transactions locally without interacting with the Bitcoin Cash network. This is useful when writing automated tests for your contracts, or when debugging your contract locally.
1313

1414
The `MockNetworkProvider` has extra methods to enable this local emulation such as `.addUtxo()` and `.setBlockHeight()`.
1515
You can read more about the `MockNetworkProvider` and automated tests on the [testing setup](/docs/sdk/testing-setup) page.
1616

17+
```ts
18+
interface MockNetworkProviderOptions {
19+
updateUtxoSet?: boolean;
20+
vmTarget?: VmTarget;
21+
}
22+
```
23+
1724
The `updateUtxoSet` option is used to determine whether the UTXO set should be updated after a transaction is sent. If `updateUtxoSet` is `true` (default), the UTXO set will be updated to reflect the new state of the mock network. If `updateUtxoSet` is `false`, the UTXO set will not be updated.
1825

26+
The `vmTarget` option defaults to the current VM of `BCH_2025_05`, but this can be changed to test your contract against different BCH virtual machine targets.
27+
1928
#### Example
2029
```ts
2130
const provider = new MockNetworkProvider();
@@ -63,7 +72,7 @@ new BitcoinRpcNetworkProvider(network: Network, url: string, options?: any)
6372
The `BitcoinRpcNetworkProvider` uses a direct connection to a BCH node. Note that a regular node does not have indexing, so any address of interest (e.g. the contract address) need to be registered by the node *before* sending any funds to those addresses. Because of this it is recommended to use a different network provider unless you have a specific reason to use the RPC provider.
6473

6574
:::caution
66-
The `BitcoinRpcNetworkProvider` does not currently support CashTokens. If you want to use CashTokens, please use the `ElectrumNetworkProvider` instead.
75+
The `BitcoinRpcNetworkProvider` does not currently support CashTokens. If you want to use CashTokens, use the `ElectrumNetworkProvider` instead.
6776
:::
6877

6978
#### Example

0 commit comments

Comments
 (0)