[Release] New @celo/abis
library to conveniently import (core) contract ABIs
#10310
arthurgousset
started this conversation in
General
Replies: 1 comment 4 replies
-
I have been playing around with this import { registryABI } from "@celo/abis/types/wagmi";
import { readContracts } from "wagmi";
export const useProposals = () => {
const REGISTRY_CONTRACT_ADDRESS =
"0x000000000000000000000000000000000000ce10";
const getAllProposals = async () => {
const data = await readContracts({
contracts: [
{
address: REGISTRY_CONTRACT_ADDRESS,
abi: registryABI,
functionName: "getAddressForString",
args: ["StableTokenEUR"],
},
],
});
console.log("data", data);
};
return { getAllProposals };
};
Working Example - import { governanceABI, registryABI } from "@/utils/Celo";
import {} from "@rainbow-me/rainbowkit";
import { readContracts } from "wagmi";
export const useProposals = () => {
const REGISTRY_CONTRACT_ADDRESS =
"0x000000000000000000000000000000000000ce10";
const getAllProposals = async () => {
const governanceAddress = (
await readContracts({
contracts: [
{
address: REGISTRY_CONTRACT_ADDRESS,
abi: registryABI,
functionName: "getAddressForString",
args: ["Governance"],
},
],
})
)[0];
if (governanceAddress.result) {
const governanceProposals = (
await readContracts({
contracts: [
{
address: governanceAddress.result,
abi: governanceABI,
functionName: "getDequeue",
},
],
})
)[0];
// convert bigint to int
const proposals = governanceProposals.result!.map((proposal: any) => {
return parseInt(proposal);
});
console.log("proposals", proposals);
}
};
return { getAllProposals };
}; Suggestions:
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all 👋
TLDR
We just released a new @celo/abis library.
We hope this helps you import (core) contract ABIs into your JS/TS application more conveniently and helps you access Celo's core contracts more easily.
Usage
Here is an example of how you can import core contract ABIs using
@celo/abis
:Next steps
Please let us know if you run into any issues or have any feature requests.
All comments and suggestions welcome! 🙏
Beta Was this translation helpful? Give feedback.
All reactions