@protokoll-eth/abi
v0.4.0
Published
ABIs and deployment addresses for the protokoll EC-VRF contracts on Monad
Maintainers
Readme
@protokoll-eth/abi
ABIs and deployment addresses for the protokoll EC-VRF contracts on Monad.
npm install @protokoll-eth/abiNo runtime dependencies. ABIs are exported as as const literals so viem and wagmi infer argument and return types automatically.
Usage
Request randomness from a consumer (viem)
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { monadVrfAdapterAbi, activeDeployment } from '@protokoll-eth/abi'
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const client = createWalletClient({
account,
transport: http('https://testnet-rpc.monad.xyz'),
})
const fee = 80_000_000_000_000_000n // 0.08 MON
await client.writeContract({
address: activeDeployment.adapter,
abi: monadVrfAdapterAbi,
functionName: 'requestRandomness',
args: ['0x...32-byte-roundId...'],
value: fee,
chain: undefined,
})Watch fulfillment events
import { createPublicClient, http, parseAbiItem } from 'viem'
import { monadVrfAdapterAbi, activeDeployment } from '@protokoll-eth/abi'
const client = createPublicClient({
transport: http('https://testnet-rpc.monad.xyz'),
})
const unwatch = client.watchContractEvent({
address: activeDeployment.adapter,
abi: monadVrfAdapterAbi,
eventName: 'RandomnessFulfilled',
onLogs: (logs) => {
for (const log of logs) {
console.log(log.args.roundId, log.args.beta, log.args.callbackOk)
}
},
})Implementing the consumer side
iRandomnessAdapterAbi is the minimal callback ABI (fulfillRandomness(bytes32, bytes32)) that any contract receiving randomness implements. Use it to encode/decode the callback if you need to mock it in tests or call it from off-chain.
How the ABIs are generated
src/abis.ts is generated by @wagmi/cli from the forge build artifacts under packages/protokoll/out/. To refresh after a contract change:
cd packages/protokoll && forge build
cd ../abi && pnpm generateThe CI publish workflow does both steps automatically before publishing, so the published ABIs always match what was last compiled.
Exports
| Export | What it is |
|--------------------------|------------------------------------------------------------------------------------------|
| monadVrfAdapterAbi | Full ABI of MonadVRFAdapter (request/fulfill, views, events, errors). |
| monadVrfVerifierAbi | ABI of MonadVRFVerifier.verifyProof - useful for off-chain proof checks against RPC. |
| iRandomnessAdapterAbi | Consumer-side fulfillRandomness(bytes32, bytes32) interface. |
| monadTestnet | Chain metadata: chainId, rpc, explorer, requestFee, requestFeeWei (bigint). |
| deployments | Versioned deployment list (newest first). active: true marks the live one. |
| activeDeployment | Shortcut for the entry with active: true. Currently v0.4.0. |
| getDeployment(version) | Look up a specific historical deployment by version string. |
Deployments
| Version | Status | Adapter |
|---------|------------|----------------------------------------------|
| v0.4.0 | active | 0xa327402C4eED5862adC123b9b1b93acA475C4668 |
| v0.3.0 | deprecated | 0x9c46878D6736eDC7eAF135DB6B3B2A9Dab2A756F |
| v0.2.0 | deprecated | 0x7782a54741dd9Dac95a8a79F181EFB97Bac2Dd19 |
| v0.1.x | deprecated | 0xe7f01914d7547d08d155ba47ee9616ee7d504b21 |
See docs.protokoll.dev/guide/deployments for verifier addresses, deploy transactions, and the rationale behind each version.
Versioning
This package's version tracks the active contract version. 0.4.0 exports the v0.4.0 contracts as the default. Older deployments stay reachable through getDeployment('v0.3.0') etc. so existing integrators can pin to a historical address without forking the package.
License
MIT
