Walkthrough: Adding ID Specific Price Data
Add data for specific NFT token ID within a topic
Add data using a specific ID within a topic, for example, a specific NFT ID for a topic dedicated to appraising NFTs of a particular collection. In this case, we say that the resultant time series of appraisals for any particular NFT ID is a subtopic within the topic.
Complete Example:
/**
* @notice Example for calling a protocol function with a prediction value from the Allora Adapter
*
* @param protocolFunctionArgument An argument for the protocol function
* @param alloraAdapterData The signed data from the Allora Adapter
*/
function callProtocolFunctionWithAlloraAdapterPredictionValue(
uint256 protocolFunctionArgument,
AlloraAdapterNumericData calldata alloraAdapterData
) external {
uint256 value = alloraAdapter.verifyData(alloraAdapterData);
_protocolFunctionRequiringPredictionValue(protocolFunctionArgument, value);
}
function _protocolFunctionRequiringPredictionValue(uint256 protocolFunctionArgument, uint256 value) internal {
// use arguments and value
}
Step by Step Guide:
- Create an upshot API key by creating an account (opens in a new tab).
- Call the Adapter Asset Appraisals API using the
topicId
found in the deployed topics list and the correctchainId
. For example, if you use sepolia, you would provideethereum-11155111
. Specify thenftId
that you would like data for at the end of the address string for the nft collection, like0x42069abfe407c60cf4ae4112bedead391dba1cdb/1465
- Construct a call to the Allora Adapter contract on the chain of your choice (options listed under deployments) using the returned
signature
andnumeric_data
as follows.
Creating the Transaction:
await alloraAdapter.verifyData({
signedNumericData: [{
signature: signature,
numericData: {
topicId: topicId,
timestamp: timestamp,
numericValue: numericValue,
extraData: extraData
}
}],
extraData: '0x'
})
UpshotAdapter upshotAdapter = UpshotAdapter(0x238D0abD53fC68fAfa0CCD860446e381b400b5Be);
SignedNumericData[] memory signedNumericData = new SignedNumericData[](1);
signedNumericData[0] = SignedNumericData({
signature: signature,
numericData: NumericData({
topicId: topicId,
timestamp: timestamp,
numericValue: numericValue,
extraData: extraData
});
});
upshotAdapter.verifyData(UpshotAdapterNumericData({
signedNumericData: signedNumericData,
extraData: ''
}));
Notes
- The API endpoint uses
snake_case
, while the smart contract usescamelCase
for attribute names. - Ethers.js does not accept
''
forextraData
. EmptyextraData
should be denoted with'0x'
.
Code Links
- Open source adapter code (opens in a new tab)
- IAlloraAdapter (opens in a new tab), including the structs used for Solidity code.