UidLookup Precompile
The UidLookup precompile maps an EVM address to the UIDs of neurons that have associated it via the associate_evm_address extrinsic.
- Address:
0x0000000000000000000000000000000000000806 - Source code: UidLookup reference
See also: Associating an EVM Key.
Function
| Function | Parameters | State mutability | Description |
|---|---|---|---|
uidLookup(uint16 netuid, address evm_address, uint16 limit) | address | view | Allows for UID lookup when provided with EVM address. |
Usage
ABI
The canonical ABI is defined in the UidLookup precompile ABI source file. If you have a local copy of the source files, you can import the ABI and contract address into your project as shown below:
import { IUIDLookupABI, IUID_LOOKUP_ADDRESS } from "./contracts/uidLookup";
Look Up Neurons Associated with an EVM Address
import { ethers } from "ethers";
import { IUIDLookupABI, IUID_LOOKUP_ADDRESS } from "./contracts/uidLookup";
const provider = new ethers.JsonRpcProvider("YOUR_RPC_URL");
const uidLookup = new ethers.Contract(
IUID_LOOKUP_ADDRESS,
IUIDLookupABI,
provider,
);
const netuid = 1;
const evmAddress = "0xYourNeuronEvmAddress";
const results = await uidLookup.uidLookup(netuid, evmAddress, 10);
for (const item of results) {
console.log(`UID ${item.uid} associated at block ${item.block_associated}`);
}