# Example - CAKE/BUSD rate on Pancaksewap

#### This demo is available [here](https://web3-demo.bubbleapps.io/version-test/web3_read_contract)

To get started, open the [Pancakeswap router contract on bscscan](https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e#readContract) and find the *getAmountsOut* function.\
This function calculates the rates for given tokens pair (CAKE/BUSD in our case)\
Open it and see what parameters it needs.

<figure><img src="https://163529783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGXQwv3RyfW5Yi0SKag6n%2Fuploads%2FnGbaO2sNgzwdRrtxQCSD%2FScreenshot%202022-12-06%20at%2017.50.18.png?alt=media&#x26;token=29132434-f5d7-4ded-93f3-2e8c86c1b1fa" alt=""><figcaption></figcaption></figure>

### Action name

```
getAmountsOut
```

### Parameter 1

We will not get into details of how and why, but in short, the Parameter 1 must be the amount of token we want to get rate for, so in our case it is CAKE amount. \
Notice that it is uint256 type, it means that we must convert the amount to WEI.\
We will do the conversion by using the [To Wei function from Utils element](https://docs.novabloq.com/web3-metamask/elements-details/web3-utils/to-wei) (see in the demo editor)

```
Web3 Utils To Wei Result
```

### Parameter 2

This must be an array of tokens contract addresses that we want to get rate for.\
\&#xNAN;*Cake: 0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82*\
\&#xNAN;*BUSD: 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56*\
\
And write it in array type with square brackets, and use double quotes for each parameter in array

```
["0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82","0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56"]
```

### Result

Use the **Contract Read event**\
The result will be available only after this event triggers.\
In our case, the result will come in an array format, where the first item is the amount we have indicated and the second is the rate.

```javascript
["1000000000000000000","3939845677320195487"]
```

Remember that the whole response is in text format, so this array is actually a simple text.\
So, using Bubble feature find and replace, we will extract the second item from array.\
See in demo editor how exactly.\
Now the rate is in WEI format. We will use the [From Wei action from Utils element](https://docs.novabloq.com/web3-metamask/elements-details/web3-utils/from-wei)\
\
And here it is, the result of our read contract will be in From Wei state.\
\
**The rate for 1 Cake to BUSD is** (6 Dec 2022)**:**

```
3.939845677320195487
```

Now we can do whatever we could need, like convert it to number, round it to 2 decimals or save in database.<br>

{% embed url="<https://discord.gg/HWfg853N6d>" %}
Our team is active on Discord. Join for discussions and support
{% endembed %}
