Skip to content

Commit

Permalink
fix: add accounts docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiorigam committed Nov 22, 2023
1 parent 1f1952c commit f18c7a0
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
32 changes: 32 additions & 0 deletions docs/examples/thorest-client/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
HttpClient,
ThorestClient
} from '@vechainfoundation/vechain-sdk-network';

// Url of the testnet network
const _testnetUrl = 'https://testnet.vechain.org/';

// Testnet network instance
const testNetwork = new HttpClient(_testnetUrl);

// Thorest client testnet instance
const thorestTestnetClient = new ThorestClient(testNetwork);

// Get account details
const accountDetails = await thorestTestnetClient.accounts.getAccount(
'0x5034aa590125b64023a0262112b98d72e3c8e40e'
);
console.log(accountDetails);

// Get account code
const accountCode = await thorestTestnetClient.accounts.getBytecode(
'0x5034aa590125b64023a0262112b98d72e3c8e40e'
);
console.log(accountCode);

// Get account storage
const accountStorage = await thorestTestnetClient.accounts.getStorageAt(
'0x5034aa590125b64023a0262112b98d72e3c8e40e',
'0x0000000000000000000000000000000000000000000000000000000000000001'
);
console.log(accountStorage);
8 changes: 7 additions & 1 deletion docs/templates/thorest-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ Fetches details of the latest block on the VechainThor network, representing the

Retrieves details of the finalized block, which is the latest block confirmed by the network consensus.

These methods demonstrate how the Thorest-client simplifies the process of fetching block-related information, providing developers with straightforward ways to integrate VechainThor blockchain data into their applications.
These methods demonstrate how the Thorest-client simplifies the process of fetching block-related information, providing developers with straightforward ways to integrate VechainThor blockchain data into their applications.

## Accounts

The Thorest-client extends its functionality to provide seamless access to account-related information on the VechainThor network. The following code exemplifies how developers can utilize the Thorest-client to interact with accounts:

[example](examples/thorest-client/accounts.ts)
40 changes: 40 additions & 0 deletions docs/thorest-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,43 @@ Fetches details of the latest block on the VechainThor network, representing the
Retrieves details of the finalized block, which is the latest block confirmed by the network consensus.

These methods demonstrate how the Thorest-client simplifies the process of fetching block-related information, providing developers with straightforward ways to integrate VechainThor blockchain data into their applications.

## Accounts

The Thorest-client extends its functionality to provide seamless access to account-related information on the VechainThor network. The following code exemplifies how developers can utilize the Thorest-client to interact with accounts:

```typescript { name=accounts, category=example }
import {
HttpClient,
ThorestClient
} from '@vechainfoundation/vechain-sdk-network';

// Url of the testnet network
const _testnetUrl = 'https://testnet.vechain.org/';

// Testnet network instance
const testNetwork = new HttpClient(_testnetUrl);

// Thorest client testnet instance
const thorestTestnetClient = new ThorestClient(testNetwork);

// Get account details
const accountDetails = await thorestTestnetClient.accounts.getAccount(
'0x5034aa590125b64023a0262112b98d72e3c8e40e'
);
console.log(accountDetails);

// Get account code
const accountCode = await thorestTestnetClient.accounts.getBytecode(
'0x5034aa590125b64023a0262112b98d72e3c8e40e'
);
console.log(accountCode);

// Get account storage
const accountStorage = await thorestTestnetClient.accounts.getStorageAt(
'0x5034aa590125b64023a0262112b98d72e3c8e40e',
'0x0000000000000000000000000000000000000000000000000000000000000001'
);
console.log(accountStorage);

```

0 comments on commit f18c7a0

Please sign in to comment.