Got a cool example to share? Get listed here! Submit it now.

useChainlinkFunctions()

Collection of community submitted examples for Chainlink Functions

Get inspired from quick examples

Chainlink Functions, a new self-service platform that allows anyone to write serverless code to fetch any data from any API and run custom compute on Chainlink's network. Learn from examples created by the community or contribute your own!
Learn more about Chainlink Functions

Entity for an address from the Arkham API

Submitted by:
Arkham Team
This Function returns the entity ID of a given address. The entity ID is a string, and represents a slugified version of the entity's name. For example, Binance -> binance. The address is the only required parameter, and an API key is the only required secret.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 // This Function returns the entity ID of the input address. Entity IDs are strings representing // slugified version of the entity's name. They can be used in other functions to Arkham's API if // you'd like to find more information about the entity and its on-chain footprint. // An Arkham API key is required to use this function. Apply for one here: https://docs.google.com/forms/d/e/1FAIpQLSfJum3MJwq8niPhNkAlNC08wzLKWyNR18vKUN41mnOG3MQkfg/viewform?usp=sf_link const address = args[0] // Validate address input. if (address.length != 42) { throw Error("invalid address") } // Validate required secret. if (!secrets.ARKHAM_API_KEY) { throw Error("api key required") } // Make the request to the /intelligence/address/:address/all endpoint. const url = `https://api.arkhamintelligence.com/intelligence/address/${address}/all` const resp = await Functions.makeHttpRequest({url, headers: {'API-Key': secrets.ARKHAM_API_KEY}}) const data = resp["data"] if (resp.error) { console.error(error) throw Error("Request failed") } // Since we used the /all endpoint, we get data in the form of a chain map (see const declaration). // In very rare cases, an address will have a different entity based on the chain. In those cases, // you can choose which chain you'd like to privilege. let entityId = "" for (const [chain, intel] of Object.entries(data).sort()) { // Sort so that output is deterministic. // Choose the chain with the first non-null arkhamEntity field. if (intel.arkhamEntity !== undefined) { entityId = intel.arkhamEntity.id break } } return Functions.encodeString(entityId)