Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature add readme #20

Merged
merged 9 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
node_modules
test.js
.vscode/launch.json
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### 1.0.0 (2024-7-22)

##### Solana Keyring Implementation

- Implemented Keyring functionality to enable account generation and export keys
- Added getAccounts() method to fetch list of generated accounts
- Added importWallet() to import account using privateKey
- Added initial test
- Added functionality to sign message
- Added get balance method to fetch SOL balance of an account
- Added functionality to sign SOL and fungible tokens transfer transaction
- Added functionality to broadcast a signed transaction
- Added functionality to get estimated fee for a transaction
- Added functionality to accept priority fee for a transaction
- Added test cases
- Added readme
79 changes: 79 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# vault-SOL-controller<code><a href="https://www.docker.com/" target="_blank"><img height="50" src="https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"></a></code>

[![npm version](https://badge.fury.io/js/@getsafle%2Fvault-sol-controller.svg)](https://badge.fury.io/js/@getsafle%2Fvault-sol-controller) <img alt="Static Badge" src="https://img.shields.io/badge/License-MIT-green"> [![Discussions][discussions-badge]][discussions-link]
<img alt="Static Badge" src="https://img.shields.io/badge/sol_controller-documentation-purple">



## Install

`npm install --save @getsafle/vault-sol-controller`

## Initialize the solana Controller class

```
const { KeyringController, getBalance } = require('@getsafle/vault-sol-controller');

const solController = new KeyringController({
// 12 words mnemonic to create wallet
mnemonic: string,
// network - type of network [TESTNET|MAINNET]
// default is MAINNET even if no network is passed
network: string (TESTNET | MAINNET)
});
```

## Methods

### add new account

```
const keyringState = await solController.addAccount();
```

### Export the private key of an address present in the keyring

```
const privateKey = await solController.exportPrivateKey(address);
```

### Get all accounts in the keyring

```
const privateKey = await solController.getAccounts();
```

### Sign a transaction

```
const signedTx = await solController.signTransaction(solTx);

STX transfer transaction:
solTx: {from, to, amount, txnType}

Token transfer transaction:
solTx: {from, to, amount, txnType, token}

transactionType = 'NATIVE_TRANSFER' || 'TOKEN_TRANSFER'
```

### Sign a message

```
const signedMsg = await solController.signMessage(msgString, address);
```

### Get fees

```
const fees = await solController.getFees(rawTransaction);
```

### Get balance

```
const balance = await getBalance(address, network); // if network !== TESTNET then it will fetch mainnet balance
```

[discussions-badge]: https://img.shields.io/badge/Code_Quality-passing-rgba
[discussions-link]: https://github.com/getsafle/vault-sol-controller/actions
Loading
Loading