https://github.com/njokuscript/blowfishjs
A Typescript/Javascript library for interacting with the Blowfish APIs
https://github.com/njokuscript/blowfishjs
javascript security solana web3
Last synced: about 1 year ago
JSON representation
A Typescript/Javascript library for interacting with the Blowfish APIs
- Host: GitHub
- URL: https://github.com/njokuscript/blowfishjs
- Owner: njokuScript
- License: mit
- Created: 2022-12-21T16:10:40.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-01T03:32:10.000Z (over 3 years ago)
- Last Synced: 2025-04-05T12:33:42.678Z (about 1 year ago)
- Topics: javascript, security, solana, web3
- Language: TypeScript
- Homepage: https://blowfish.xyz/
- Size: 532 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
The Blowfish javascript library compatible with browsers and Node.js backends
## Installation
To get started, install the Blowfish JS package from npm.
```sh
npm install @njoku/blowfishjs
```
For browsers, via jsDelivr CDN:
```html
```
## Getting Started
To create a new Blowfish instance, you have to pass in your blowfish API key in the constructor.
```js
// in browser
const blowfish = new Blowfish(BLOWFISF_API_KEY);
// in nodejs
const Blowfish = require('@njoku/blowfishjs');
const blowfish = new Blowfish(BLOWFISF_API_KEY);
```
## Scanning a transaction
Scan transactions in order to receive recommended actions, tailored warnings and human-readable simulation results explaining what the transaction will do.
```js
const params = {
chain: 'solana',
chainId: 101,
transactions: [
'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAIFRcely+GNw4HsXvDZ2vi8ZHSvnfYAbuGTK5XjxGyUJ60JrJ+YHtCWDBeA0FSzvcigxpHxRg4haKu4qFquf9nwtxDLqeLGT1Y9D3jvRn8BJWyEq8LHFGZpD+vfskCcD4EGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGp9UXGSxWjuCKhF9z0peIzwNcMUWyGrNE2AYuqUAAAD1D6qTjIhI3IvLaoY+jcKrCp7I8+Di2XK6tV2y4c2liAgMDAgQABAQAAAADAgABDAIAAAAA4fUFAAAAAA==',
],
userAccount: '5hPhdbH8bVXNrx2Cy9bM6bXkZhNUGAUizq9QQW7zMguz',
dappUrl: 'https://scammer.com',
}
const evaluationResult = await blowfish.scanTransaction(params);
```
| **Parameter** | **Type** | **Description** |
| ------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `chain` | *string* | Blockchain to perform the transaction scanning on. See the list of supported blockchains here |
| `chainId` | *number* | Network identifier of the blockchain . |
| `transactions` | *array/object* | For the Solana chain, transactions is an array of base58 or base64 encoded Solana transactions. For the Ethereum and Polygon chain, the transaction is an object containing the *from*, *to*, *value* and *data* properties. |
| `userAccount` | *string* | A hex-representation of the user account who is being asked to sign the supplied transaction addresses. |
| `dappUrl` | *string* | DApp domain proposing these transactions |
## Supported Chains
* ### Solana
* Devnet
* Testnet
* Mainnet
* ### Ethereum/Polygon
- Ethereum Mainnet
- Goerli Testnet
- Polygon Mainnet
### Ethereum and Polygon are equivalent when it comes to functionality as well as request and response formats.