Skip to content

Commit 8fd3778

Browse files
committed
docs: update readme
1 parent 109fed4 commit 8fd3778

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

README.md

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,54 @@ vechain-getters/
170170
└── README.md # This file
171171
```
172172
173-
## 🔧 Adding VeChain Getters
173+
## 🔧 Adding New Contract Getters
174174
175-
The examples are set up and ready to showcase your getters. To add real VeChain functionality:
175+
This library provides getters for specific VeChain smart contracts. To add support for new contracts:
176176
177-
1. **Implement getters** in `packages/contract-getters/src/index.ts`:
177+
1. **Create a new contract module** in `packages/contract-getters/src/`:
178178
179179
```typescript
180-
export { createClient } from './client';
181-
export { getAccountBalance } from './getters/account';
182-
export { getLatestBlock } from './getters/block';
183-
export { getTransaction } from './getters/transaction';
180+
// packages/contract-getters/src/myContract/balance.ts
181+
import { type GetterOptions } from '../types/common';
182+
import { createVeChainClient } from '../client';
183+
184+
export async function getMyContractBalance(
185+
address: string,
186+
options?: GetterOptions,
187+
): Promise<bigint> {
188+
const client = createVeChainClient(options);
189+
190+
// Contract interaction logic here
191+
// Let smart contract errors bubble up naturally
192+
const result = await client.contracts.myContract.balanceOf(address);
193+
return result;
194+
}
184195
```
185196
186-
2. **Update examples** to use the new getters:
187-
- Update imports in both example applications
188-
- Add real VeChain network calls
189-
- Implement proper error handling and loading states
197+
2. **Export from module index**:
190198
191-
3. **Add TypeScript types** for better developer experience
199+
```typescript
200+
// packages/contract-getters/src/myContract/index.ts
201+
export { getMyContractBalance } from './balance';
202+
```
203+
204+
3. **Add to main exports** in `packages/contract-getters/src/index.ts`:
205+
206+
```typescript
207+
export * from './myContract';
208+
```
209+
210+
4. **Update examples** to demonstrate the new getter:
211+
- Add usage examples in `examples/nodejs-example/src/index.ts`
212+
- Follow existing patterns for error handling and output formatting
213+
214+
**Guidelines:**
215+
216+
- Keep functions simple and focused on single contract calls
217+
- Let smart contract errors propagate naturally (don't catch unless necessary)
218+
- Use consistent parameter patterns (`address`, `options?`)
219+
- Add proper TypeScript types for all parameters and return values
220+
- Follow existing naming conventions (`get[Contract][Function]`)
192221
193222
## 🤝 Contributing
194223

0 commit comments

Comments
 (0)