Socket
Socket
Sign inDemoInstall

abi-wan-kanabi

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abi-wan-kanabi - npm Package Compare versions

Comparing version 2.1.0-rc.4 to 2.1.0-rc.5

dist/config.d.ts

3

dist/generate.js

@@ -65,3 +65,3 @@ #!/usr/bin/env node

// function calls (\`const ret = contract.your_function()\`) and you'll get
// helpful editor autocompletion, linting errors ...
// helpful editor autocompletion, linting errors ... for free ! Enjoy !
}

@@ -86,1 +86,2 @@ main().catch(console.error)`;

run().catch(console.error);
//# sourceMappingURL=generate.js.map
{
"name": "abi-wan-kanabi",
"version": "2.1.0-rc.4",
"version": "2.1.0-rc.5",
"description": "Abi parser for Cairo smart contracts, based on wagmi abitype",

@@ -9,4 +9,8 @@ "main": "index.js",

},
"files": ["dist"],
"scripts": {
"generate": "tsc && node dist/generate.js",
"build": "tsc",
"clean": "rm -rf dist",
"prepack": "npm run clean && npm run build",
"generate": "npm run build && node dist/generate.js",
"test": "vitest",

@@ -13,0 +17,0 @@ "coverage": "vitest run --coverage",

@@ -56,2 +56,32 @@ # ABI-WAN-KANABI

### Usage with `starknet.js`
Let's say you want to interact with the [Ekubu: Core](https://starkscan.co/contract/0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b) contract using starknet.js, using abiwan you can get the correct types for the contract's functions
You need to first get the **Abi** of the contract and export it in a typescript file, you can do so using one command combining both [`starkli`](https://github.com/xJonathanLEI/starkli) (tested with version 0.2.3) and `npx abi-wan-kanabi`:
```bash
starkli class-at "0x0000000dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b" --network mainnet | npx abi-wan-kanabi --input /dev/stdin --output abi.ts
```
The command will get the contract class from the network, and pipe it to abiwan, which will generate `abi.ts` with `export const ABI = [YOUR ABI HERE]` that we'll import later to get type information, the command will also print a helpful snippet that you can use to get started
```javascript
import { Contract, RpcProvider, constants } from 'starknet';
import { ABI } from './abi';
async function main() {
const address = "CONTRACT_ADDRESS_HERE";
const provider = new RpcProvider({ nodeUrl: constants.NetworkName.SN_MAIN });
const contract = new Contract(ABI, address, provider).typedv2(ABI);
const version = await contract.getVersion();
console.log("version", version)
// Abiwan is now successfully installed, just start writing your contract
// function calls (`const ret = contract.your_function()`) and you'll get
// helpful editor autocompletion, linting errors ...
}
main().catch(console.error)
```
### Build

@@ -58,0 +88,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc