You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use abitype instead of TypeChain in my Hardhat project. I've read the abitype documentation but still can't figure out how to implement it. Here's my current code:
import{assert,expect}from"chai"import{ethers}from"hardhat"import{SimpleStorage,SimpleStorage__factory}from"../typechain-types"import{Abi,ExtractAbiFunctions,ExtractAbiFunction}from"abitype"// import { erc20Abi } from 'abitype/abis'// import SimpleStorage from "../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json"// import SimpleStorageArtifact from "../abi-ts/SimpleStorage.sol/SimpleStorage"// const simpleStorageAbi = SimpleStorageArtifact.abi// type Result = ExtractAbiFunctions<typeof simpleStorageAbi>// type Result = ExtractAbiFunction<// typeof SimpleStorageArtifact.abi,// "retrieve"// >describe("SimpleStorage",()=>{letsimpleStorageContractFactory: SimpleStorage__factoryletsimpleStorageContract: SimpleStorage// let simpleStorageContractFactory, simpleStorageContractbeforeEach(async()=>{simpleStorageContractFactory=awaitethers.getContractFactory("SimpleStorage")simpleStorageContract=awaitsimpleStorageContractFactory.deploy()})it("Should start with a favorite number of 0",async()=>{constcurrentvalue=awaitsimpleStorageContract.retrieve()constexpectedValue="0"assert.equal(currentvalue.toString(),expectedValue)})it("Should update when we call store",async()=>{constexpectedValue="7"consttransactionResponse=awaitsimpleStorageContract.store(expectedValue)awaittransactionResponse.wait(1)constcurrentValue=awaitsimpleStorageContract.retrieve()assert.equal(currentValue.toString(),expectedValue)})
Key questions:
How to properly import and use contract ABIs with abitype?
How to generate type-safe contract interfaces like TypeChain does?
What's the equivalent of Contract__factory and Contract pattern in abitype?
I'd appreciate a concrete example showing how to convert this TypeChain setup to abitype. ❤️
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to use abitype instead of TypeChain in my Hardhat project. I've read the abitype documentation but still can't figure out how to implement it. Here's my current code:
Key questions:
I'd appreciate a concrete example showing how to convert this TypeChain setup to abitype. ❤️
Beta Was this translation helpful? Give feedback.
All reactions