Deploy your own price feed

In this tutorial, we’ll deploy our own price feed for use with synthetic tokens on testnet. Note: this will be necessary if the identifier (or underlying asset) you want to track isn’t supported. For a list of supported identifiers, see identifiers.json.

If you’d like more information on what an identifier is and how to configure a price feed, please see our explainer.


All of our tutorials require that you complete the steps in Prerequisites.

Deploy the contract to rinkeby

The UMA testnet contracts are deployed to rinkeby, so for the rest of the tutorial, it’s assumed you’ll be interacting with that network.

A few notes on the wallet you should use to interact with the Rinkeby testnet:

  • You should not do this with a wallet that holds mainnet assets.

  • You should make sure that this wallet has Rinkeby ETH. If not, you can use this faucet to get some.

  • You’ll need the mnemonic (seed phrase) for this wallet to add it to truffle, so make sure it’s generated from a mnemonic. If you create the wallet through Metamask, for example, it will give you a mnemonic to write down.

You’ll need to add this wallet to your environment by entering the following command replacing your mnemonic here with your mnemonic:

export MNEMONIC="your mnemonic here"

You’ll need to open the truffle console to directly send commands to the blockchain. To do so, run the following command from the core/ directory:

$(npm bin)/truffle console --network rinkeby_mnemonic

Now that you’re in the truffle console, you can deploy your new price feed contract:

> let price_feed = await

Next, you’ll want to print out the address of your new contract, so you can point your scripts and contracts at it:

> price_feed.address

You should see the price feed address printed in the console. Copy and paste that address somewhere so you have it on hand. You can now exit the truffle console by pressing ctrl-c a few times.

Add your price feed to your local configuration

To use your price feed with any of the UMA scripts, you’ll need to add it to the configuration. To do so, open the file core/networks/4.json. Find the follwing lines near the end of that file:

    "contractName": "LeveragedReturnCalculator",
    "address": "0x756B875Da7c30B8Ab15fa05cFEc28a9d7065abeA"

Once you’ve found those lines, change them to the following replacing PRICE_FEED_ADDRESS_HERE with the address for the price feed contract you deployed above:

    "contractName": "LeveragedReturnCalculator",
    "address": "0x756B875Da7c30B8Ab15fa05cFEc28a9d7065abeA"
    "contractName": "ManualPriceFeed",
    "address": "PRICE_FEED_ADDRESS_HERE"

Save the file, and run the following command from the core/ directory:

$(npm bin)/apply-registry

You’ve now updated the configuration to use your price feed contract.

Upload prices to your price feed contract

To use your price feed, you’ll need to add a price to it. You’ll need to add a price for one of the identifiers that’s already approved in the testnet DVM. We reccomend using the identifier Custom Index (1).

To push a price, you’ll need to know the price you want to push and the unix timestamp (must be now or in the past). Run the following command (from the core/ directory) replacing <price> with your price and <time> with the unix timestamp:

$(npm bin)/truffle exec scripts/ManualPublishPriceFeed.js --identifier 'Custom Index (1)' --price <price> --time <time> --network=rinkeby_mnemonic

Some notes on using this command:

  • The price will be multiplied by 10^18 to convert it to a fixed point integer that Solidity can understand.

  • You can repeat this command whenever you want to change the price. You’ll only need to make sure that the timestamp is greater than the previous timestamp you provided, but not in the future.

Deploy a TokenizedDerivative instance that deplends on this price feed

To deploy a Tokenized Derivative that uses your price feed, you’ll want to change the priceFeedAddress parameter to your price feed address from above and the product parameter to Custom Index (1) (converted to bytes32). The specific instructions for how to deploy a custom TokenizedDerivative are in this tutorial - you’ll just need to remember these two parameters.

© UMA Project 2018-2019