Deploying & Adding An Extra Token

Extra tokens are tokens that have not necessarily been added by PaySwap itself, they can be tokens representing stocks, index funds, commodities, native coins of various blockchains, etc.

Suppose you want to set-up a ramp in order to help users from around the world purchase Tesla stocks, you can deploy a Tesla token as an extra token, and add it to your ramp so users can mint/burn Tesla tokens.

In this scenario, each time a user mints Tesla tokens, the equivalent amount in USD of the number of Tesla tokens is transferred to your Stripe account (in case of automatic ramps) in order for you to be able to purchase the actual Tesla stocks from the stock market.

This model can be used to enable anyone around the world to have access to any stocks, index funds, etc.

You can replace Tesla in the example above with commodities like Gold, Silver, Bitcoin, etc.

Deploying An Extra Token

To deploy an extra token, go to your ramp's control panel menu, click on the the Deploy Extra Token button

Fill in the form with the name of the token, its ticker name as well as a stringified version of the call object for a call to an API that will return the price of the token in USD.

Let's take the example of an API call that goes like this:

const options = {
    method: 'GET',
    url: 'https://alpha-vantage.p.rapidapi.com/query',
    params: {
      function: 'TIME_SERIES_DAILY',
      symbol: 'TSLA',
      outputsize: 'compact',
      datatype: 'csv'
    },
    headers: {
      'X-RapidAPI-Key': <your_private_key>,
      'X-RapidAPI-Host': 'alpha-vantage.p.rapidapi.com'
    }
  }
const response = await axios.request(options)
  

To get the stringified version of our options object, we will open the console panel of our browser, copy the options object into it, and call the JSON.stringify function on our options' object like in the image below

Once you have the stringified version of the options' object, you can copy it into the call object field in the form to deploy the token and validate the transaction.

Make sure your API returns either one value that is the price of the token in USD, or a series of values in CSV format of which the first valid number is the price of the token in USD.

You can change your options object anytime by selecting the Update Extra Token Call option from the control panel of your ramp and inputting your new options object in stringified format.

Once your token has been deployed, you should be able to see its address listed in the parameters' section of your ramp like in the image below under the Extra Tokens field. If you don't reload the page.

Copy the address by clicking on the icon right next to it and go back to your ramp's control panel.

Select the Add Extra Token button, paste the previously copied address in the Extra Token Address field, and validate the transaction.

.

The next step is to add this newly deployed token to your ramp as a token market.

Adding An Extra Token

To add your newly created token as a token market so users can mint/burn it, go to your ramp's control panel menu, click on the Add Token Market button, and validate the form.

You should be able to see your token added in the bottom left section of your ramp's panel like in the image below

To enable users to mint your new token, you also have to have the ramp fetch its price from your API.

To do so, select the token, then click on the Control Panel button, and from the menu, click on the Fetch Price From API button. Refresh until you get a real number and not a NaN

The platform uses your API to get the token's price in USD and then converts its USD price into that of the native coin of your ramp's blockchain. Since in this case, our ramp is deployed on the Fantom blockchain, it fetches the TSLA price in USD and then converts it to FTM.

Click on the Set Prices button and then on the Continue button. Validate the transaction.

You should be able to see the price updated in the parameters section of your ramp like in the image below

The last step is to create a bounty and attach it to your new token market so users can start minting and burning your TSLA tokens.

Make sure when they do, that you actually go and purchase the real TSLA stock otherwise, your bounty might get claimed.

Finding An API

You can find multiple APIs that return the real-time price of most assets by doing a simple Google search.

The API given in the example above is the alpha-vantage API from Rapid API. The site gives instructions on how to query for the prices of multiple stocks, cryptocurrencies, FIAT currencies, etc.

To query a stock for instance we use the call object below:

const options = {
  method: 'GET',
  url: 'https://alpha-vantage.p.rapidapi.com/query',
  params: {
    function: 'TIME_SERIES_DAILY',
    symbol: 'MSFT',
    outputsize: 'compact',
    datatype: 'csv'
  },
  headers: {
    'X-RapidAPI-Key': <your_private_key>,
    'X-RapidAPI-Host': 'alpha-vantage.p.rapidapi.com'
  }
};

This call will return the daily prices of the MSFT stock in CSV format (make sure you replace your_private_key with your private key which you can get by creating an account on the site).

Replacing the MSFT ticker with any other ticker like OZ (for Gold), TSLA, as well as any other stock supported by the API, will return the prices of that stock.

A call with the object above will return a CSV object with the format below

timestamp,open,high,low,close,volume 
2024-01-22,400.0200,400.6200,393.5900,396.5100,27016902 
2024-01-19,395.7600,398.6700,393.5000,398.6700,29331136 
2024-01-18,391.7200,393.9900,390.1200,393.8700,23392068

PaySwap parses for the first valid number in the returned CSV which in this case is the open price of the stock: 400.0200

If your API returns a different set of responses, just make sure the returned object is in CSV format and that the first valid number is the price of the asset.

Adding Relevant Tags

We recommend you add tags to your ramp relevant to its features such as the token markets you've added to it.

If you add the XOF tag to your ramp, for instance, users looking to either mint/burn tXOF/XOF tokens can find your ramp much faster by filtering for the XOF tag from the Product Tags drop-down menu at the top of the Ramps' page

To add a tag to your ramp, go to your ramp's control panel menu and select the Update Location option

Enter the tag and validate the operation. You can also add location tags by selecting the relevant countries and then the cities you operate in from the Country and City drop-downs.

Last updated