Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@typechain/ethers-v6
Advanced tools
🔌 TypeScript bindings for Ethers 6.x.x smartcontracts
This package requires TypeScript >= 4.7 and moduleResolution
to be set as node16
or nodenext
.
The main files generated by this target are <contract-name>.ts
. They declare typesafe interfaces for your contracts on
top of ethers Contract
instances:
contract.someMethod(...)
, contract.someMethod.call(...)
,
contract.someMethod.staticcall(...)
and contract.someMethod.send(...)
contract.interface.events.AnEvent
and filters in contract.filters.AnEvent
contract.someMethod.estimateGas(...)
on
, once
, etc) that return the same contract type.AddressLike
, meaning you can pass a signer or contract.Note: these are just type declarations to help you call the blockchain properly, so they're not available at runtime,
and all of the contracts are still instances of the same Contract
class.
This target also generates a concrete factory class for each contract, to help you deploy or connect to contract
instances. The factory classes are an extension of ethers' ContractFactory
. They serve two main purposes:
ContractFactory
class, so you don't have to load and parse the JSON
manuallyContractFactory
(since it returns plain Contract
instances).Abstract contracts or solidity interfaces are handled a bit different, because they have no bytecode. For those, a
simplified factory is generated that doesn't extends ContractFactory
, and only includes the static connect
method,
so you can easily connect to a deployed instance without having to pass the ABI manually.
Suppose you have an Erc20Token.sol
solidity interface and a DummyToken.sol
contract implementing it.
import { Wallet } from 'ethers';
import { DummyTokenFactory } from 'typechain-out-dir/DummyTokenFactory';
import { DummyToken } from 'typechain-out-dir/DummyToken';
import { Erc20TokenFactory } from 'typechain-out-dir/Erc20TokenFactory';
const provider = getYourProvider(...);
// use the concrete contract factory if you need to operate on the bytecode (ie. deploy)
async function deployTestToken(ownerPK: string): Promise<DummyToken> {
const owner = new Wallet(ownerPK, provider);
return new DummyTokenFactory(owner).deploy();
}
// to call existing contracts, a factory for both the concrete contract and for the interface
// can be used since the ABI is the same
async function getTokenBalance(walletAddress: string, tokenAddress: string): Promise<bigint> {
const token = Erc20TokenFactory.connect(tokenAddress, provider);
return token.balanceOf(walletAddress);
}
FAQs
🔌 TypeChain target for ethers-v6
The npm package @typechain/ethers-v6 receives a total of 32,385 weekly downloads. As such, @typechain/ethers-v6 popularity was classified as popular.
We found that @typechain/ethers-v6 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.