ChainlinkResource
Access via urblock.chainlink.
Query Chainlink Price Feeds (AggregatorV3) and request verifiable randomness (VRF v2.5).
Price Feeds
listPriceFeeds(params?)
List available price feed pairs.
const feeds = await urblock.chainlink.listPriceFeeds({ network: "polygon_amoy" });
Returns: ChainlinkPriceFeedListResponse
getPriceFeed(pair, params?)
Get the latest price for a pair.
const price = await urblock.chainlink.getPriceFeed("ETH/USD", {
network: "polygon_amoy",
});
Returns: ChainlinkPriceFeedDataResponse
getPriceFeedRounds(pair, params?)
Get historical round data for a pair.
const rounds = await urblock.chainlink.getPriceFeedRounds("ETH/USD", {
network: "polygon_amoy",
count: 10,
});
Returns: ChainlinkPriceRoundListResponse
getPriceFeedConfig(pair, params?)
Get configuration for a price feed (decimals, description, max_age).
const config = await urblock.chainlink.getPriceFeedConfig("ETH/USD", {
network: "polygon_amoy",
});
Returns: ChainlinkPriceFeedConfigResponse
updatePriceFeedMaxAge(pair, params)
Update the staleness threshold for a price feed consumer.
const tx = await urblock.chainlink.updatePriceFeedMaxAge("ETH/USD", {
max_age_seconds: 7200,
network: "polygon_amoy",
idempotency_key: "max-age-001",
});
Returns: TransactionShortResponse
deployPriceFeedConsumer(params)
Deploy a price feed consumer contract.
const consumer = await urblock.chainlink.deployPriceFeedConsumer({
name: "ETH/USD Price Consumer",
pair: "ETH/USD",
network: "polygon_amoy",
price_feed_address: "0x...",
max_age_seconds: 3600,
idempotency_key: "price-consumer-001",
});
Returns: ChainlinkPriceFeedConsumerDeployResponse
VRF v2.5
createVrfRequest(params)
Request verifiable random numbers.
const request = await urblock.chainlink.createVrfRequest({
consumer_id: "tok_abc123",
num_words: 2,
network: "polygon_amoy",
idempotency_key: "vrf-001",
});
Returns: ChainlinkVrfRequestResponse
getVrfRequest(id)
Get a VRF request by ID.
const request = await urblock.chainlink.getVrfRequest("vrf_abc123");
Returns: ChainlinkVrfRequestResponse
getVrfResult(id)
Get the fulfilled random numbers for a VRF request.
const result = await urblock.chainlink.getVrfResult("vrf_abc123");
Returns: ChainlinkVrfResultResponse
getVrfConsumerConfig(id)
Get VRF consumer configuration.
const config = await urblock.chainlink.getVrfConsumerConfig("tok_abc123");
Returns: ChainlinkVrfConsumerConfigResponse
updateVrfConsumerConfig(id, params)
Update VRF consumer configuration.
const tx = await urblock.chainlink.updateVrfConsumerConfig("tok_abc123", {
callback_gas_limit: 200000,
request_confirmations: 5,
idempotency_key: "vrf-config-001",
});
Returns: TransactionShortResponse
deployVrfConsumer(params)
Deploy a VRF consumer contract.
const consumer = await urblock.chainlink.deployVrfConsumer({
name: "My VRF Consumer",
network: "polygon_amoy",
vrf_coordinator: "0x...",
subscription_id: "12345",
key_hash: "0x...",
callback_gas_limit: 100000,
request_confirmations: 3,
idempotency_key: "vrf-consumer-001",
});
Returns: ChainlinkVrfConsumerDeployResponse
getVrfRequestIdByIndex(id, index)
Get a request ID by its index in the consumer.
const result = await urblock.chainlink.getVrfRequestIdByIndex("tok_abc123", 0);
Returns: ChainlinkVrfRequestIdByIndexResponse
getVrfRequester(id, requestId)
Get the requester address for a VRF request.
const result = await urblock.chainlink.getVrfRequester(
"tok_abc123",
"12345",
);
Returns: ChainlinkVrfRequesterResponse