Functions
| Function | Description |
|---|---|
from(hex) | From hex string or bytes |
fromSignature(sig) | Hash function signature |
toHex(sel) | To hex string |
equals(a, b) | Compare selectors |
4-byte EVM function selector
import { Selector } from 'voltaire-effect/primitives'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'
// Schema
const selector = Schema.decodeSync(Selector.Hex)('0xa9059cbb')
// Effect: from hex
const program = Selector.from('0xa9059cbb')
// Effect.Effect<SelectorType, SelectorError>
// From function signature (hashes with keccak256)
const fromSig = Selector.fromSignature('transfer(address,uint256)')
// → 0xa9059cbb
| Function | Description |
|---|---|
from(hex) | From hex string or bytes |
fromSignature(sig) | Hash function signature |
toHex(sel) | To hex string |
equals(a, b) | Compare selectors |
const program = Effect.gen(function* () {
const a = yield* Selector.from('0xa9059cbb')
const b = yield* Selector.fromSignature('transfer(address,uint256)')
return yield* Selector.equals(a, b) // true
})