gn-provider 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +15 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ A custom BSV provider for sCrypt contracts using the WhatsOnChain API. This pack
4
4
 
5
5
  ## Prerequisites
6
6
 
7
- Before using GN Provider, you need to have sCrypt installed in your project. The recommended version is **scrypt-ts v1.3.5** or higher.
7
+ Before using GN Provider, you need to have sCrypt installed in your project. The recommended version is **scrypt-ts v1.4.5** or higher.
8
8
 
9
9
  To check your current sCrypt version:
10
10
  ```bash
@@ -35,7 +35,6 @@ During installation, the package will automatically:
35
35
 
36
36
  ```typescript
37
37
  import { GNProvider } from 'scrypt-ts/dist/providers/gn-provider';
38
- import * as bsv from 'bsv';
39
38
 
40
39
  // Initialize provider (mainnet or testnet)
41
40
  const provider = new GNProvider(bsv.Networks.mainnet);
@@ -50,14 +49,19 @@ console.log('Connected:', provider.isConnected());
50
49
  ### Using with sCrypt Contracts
51
50
 
52
51
  ```typescript
53
- import { GNProvider } from 'scrypt-ts';
54
- import * as bsv from 'bsv';
52
+ import { GNProvider } from 'scrypt-ts/dist/providers/gn-provider';
53
+ import { bsv, TestWallet } from 'scrypt-ts';
55
54
  import { MyContract } from './src/contracts/myContract';
55
+ import * as dotenv from 'dotenv';
56
+ dotenv.config();
57
+
58
+ const privateKey = bsv.PrivateKey.fromWIF(process.env.PRIVATE_KEY || '')
59
+ const woc_api_key = 'your_woc_api_key_here';
56
60
 
57
61
  async function main() {
58
62
  // 1. Initialize provider
59
- const provider = new GNProvider(bsv.Networks.testnet);
60
- await provider.connect();
63
+ const provider = new GNProvider(bsv.Networks.mainnet, woc_api_key);
64
+ const signer = new TestWallet( privateKey, provider );
61
65
 
62
66
  // 2. Load your contract artifact
63
67
  await MyContract.loadArtifact();
@@ -66,7 +70,7 @@ async function main() {
66
70
  const instance = new MyContract();
67
71
 
68
72
  // 4. Connect contract to provider
69
- instance.connect(provider);
73
+ instance.connect(signer);
70
74
 
71
75
  // 5. Deploy contract
72
76
  const deployTx = await instance.deploy(100); // Deploy with initial satoshis
@@ -83,7 +87,7 @@ main().catch(console.error);
83
87
  ### Advanced Configuration
84
88
 
85
89
  ```typescript
86
- // With API key for enhanced rate limits
90
+ // Use your API key for enhanced rate limits
87
91
  const provider = new GNProvider(
88
92
  bsv.Networks.mainnet,
89
93
  'your-woc-api-key-here'
@@ -107,7 +111,7 @@ provider.on('networkChange', (network) => {
107
111
  ### `new GNProvider(network: bsv.Networks.Network, apiKey?: string)`
108
112
  Creates a new provider instance.
109
113
  - `network`: BSV network (mainnet or testnet)
110
- - `apiKey`: Optional WhatsOnChain API key for higher rate limits
114
+ - `apiKey`: Optional. User your WhatsOnChain API key for higher rate limits
111
115
 
112
116
  ### Methods
113
117
  | Method | Description |
@@ -133,13 +137,13 @@ Creates a new provider instance.
133
137
  If you encounter any issues:
134
138
  1. Verify sCrypt version: `npm list scrypt-ts`
135
139
  2. Check provider installation: Look for `gn-provider.js` in:
136
- `node_modules/scrypt-ts/dist/bsv/providers/`
140
+ `node_modules/scrypt-ts/dist/providers/`
137
141
  3. Ensure you're using the correct network (mainnet/testnet)
138
142
  4. Verify your WhatsOnChain API key if using rate-limited operations
139
143
 
140
144
  ## Support
141
145
 
142
- For support, bug reports, or feature requests, please open an issue on our [GitHub repository](https://github.com/yourusername/gn-provider).
146
+ For support, bug reports, or feature requests, please open an issue on our [GitHub repository](https://github.com/borisjavier/gn-provider).
143
147
 
144
148
  ## License
145
149
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gn-provider",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "files": [
5
5
  "dist",
6
6
  "scripts",