Skip to content

Commit

Permalink
docs(README): improves examples
Browse files Browse the repository at this point in the history
- adds `viem` example in JS/TS section (previously missing)
- simplifies CommonJS example
  • Loading branch information
arthurgousset committed Nov 29, 2023
1 parent bca74bb commit 84d1ed0
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/protocol/abis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ or
yarn add @celo/abis
```

### In your javascript or ts
### JS/TS syntax

```ts
// json abi
import Accounts from '@celo/abis/Accounts.json'

// viem
import { accountsABI } from "@celo/abis/types/wagmi";

// ethers
import { Accounts } from '@celo/abis/types/ethers'

Expand All @@ -32,26 +35,19 @@ import Accounts from '@celo/abis/types/web3/Accounts'
import { AccountsContract } from '@celo/abis/types/truffle'
```

### In Node
### CommonJS syntax

```js
const Accounts = require("@celo/abis/Accounts.json");

// ethers
const provider = new ethers.providers.JsonRpcProvider("https://forno.celo.org");

const accounts = new ethers.Contract("[ACCOUNTS_ADDRESS]", Accounts.abi, provider);
const accounts = new ethers.Contract("0x...", Accounts.abi, ...);

// viem
const publicClient = createPublicClient({
chain: celo
transport: http()
});

const accounts = getContract({
address: "[ACCOUNTS_ADDRESS]",
address: "0x...",
abi: Accounts.abi,
publicClient
...
})
```

Expand Down

0 comments on commit 84d1ed0

Please sign in to comment.