Adding ID Specific Price Data

Add data using a specific 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:

  1. Create an upshot API key by creating an account.
  2. Call the Adapter Asset Appraisals api using the topicId found in the deployments list under 'Asset Appraisals Topic IDs' and the correct chainId. For example, if you use sepolia, you would provide ethereum-11155111. Specify the nftId that you would like data for at the end of the address string for the nft collection, like 0x42069abfe407c60cf4ae4112bedead391dba1cdb/1465
  3. Construct a call to the Allora Adapter contract on the chain of your choice (options listed under deployments) using the returned signature and numeric_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 uses camelCase for attribute names.
  • Ethers.js does not accept '' for extraData. Empty extraData should be denoted with '0x'.

Code Links