joshstevens19 / simple-uniswap-sdk

Uniswap SDK which handles the routes automatically for you, changes in trade quotes reactive subscriptions, exposure to formatted easy to understand information, bringing back the best trade quotes automatically, generating transactions for you and much more.
MIT License
188 stars 95 forks source link

UniswapError: invalid from or to contract tokens #20

Closed csidi90 closed 2 years ago

csidi90 commented 2 years ago

Im trying to use one of the examples from this repo but I keep getting this error and I can not find the reason why. I am trying to use my chainstack node provider URL which works with other modules like web3 without issues.

const uniswapPair = new UniswapPair({ // the contract address of the token you want to convert FROM fromTokenContractAddress : '0xdac17f958d2ee523a2206206994597c13d831ec7', // the contract address of the token you want to convert TO toTokenContractAddress : '0x2b591e99afe9f32eaa6214f7b7629768c40eeb39', // the ethereum address of the user using this part of the dApp ethereumAddress : '0x1624c82cdac2f518ab47ef34f497af268b6d7916', chainId : ChainId.MAINNET, providerUrl : 'myusernamen:myuserpassword@nd-095-386-530.p2pify.com', settings : new UniswapPairSettings({ // if not supplied it will use 0.005 which is 0.5% // please pass it in as a full number decimal so 0.7% // would be 0.007 slippage : 0.005, // if not supplied it will use 20 a deadline minutes deadlineMinutes : 20, // if not supplied it will try to use multihops // if this is true it will require swaps to direct // pairs disableMultihops : false, // for example if you only wanted to turn on quotes for v3 and not v3 // you can only support the v3 enum same works if you only want v2 quotes // if you do not supply anything it query both v2 and v3 uniswapVersions : [ UniswapVersion.v2, UniswapVersion.v3 ] }) });