简体   繁体   中英

How to use best use vb.net to automate task in binance smart chain or ethereum network?

Basically I want to automate some tasks in crypto currency.

For example, say I want to buy bitcoin if the price in a defi is 36k

In cefi there is an API for that.

What about in defi?

After that I need to interact with the blockchain to say, do deals with this smart contract.

As far as I know there is no API in defi.

So what should I use instead?

I did research and found sources like

https://ethereum.org/en/developers/docs/

But I don't want to build a dapps

I want to build a normal application that interact with the blockchain, like automating buying and selling coins at defi.

Where should I start?

I will give a sample

Say I do a simple exchange in spooky swap.

I would want to execute contract

https://ftmscan.com/address/0xf491e7b69e4244ad4002bc14e878a34207e38c29

and function

swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline)

With these parameters

#   Name    Type    Data
0   amountOutMin    uint256 101506649727709088
1   path    address[]   0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83
0x112dF7E3b4B7Ab424F07319D4E92F41e6608c48B
2   to  address 0x898568c58466957bedaE0e2A2457beb158a150de
3   deadline    uint256 1653213606

Simple right?

Anyone can go to spookyswap and do this with metamask.

How do I do so in vb.net (or c#)?

I did some research and some says to use nethereum

https://nethereum.com/

It seems that it's to make dapps instead of interacting with dapps.

So what should I do?

Is nethereum the way to go? Will it work with avalanche, fantom, and cronos and so on? Like metamask?

I did research on google.

The best I can come up is

https://medium.com/coinmonks/a-net-developers-workflow-for-creating-and-calling-ethereum-smart-contracts-44714f191db2

It basically says

There are many great tools available to create Ethereum Smart Contracts. It can be hard to choose between them. In this article, you will learn a simple workflow for developing Solidity smart contracts and calling their functions from C#. This workflow is well suited to .NET developers because it minimises the amount of new tools you need to know about. By using the excellent Nethereum .NET library you can continue to use the Visual Studio set of tools you are already familiar with.There are many great tools available to create Ethereum Smart Contracts. It can be hard to choose between them. In this article, you will learn a simple workflow for developing Solidity smart contracts and calling their functions from C#. This workflow is well suited to .NET developers because it minimises the amount of new tools you need to know about. By using the excellent Nethereum .NET library you can continue to use the Visual Studio set of tools you are already familiar with.

So basically it says, use Nethereum. I'll look into it.

Also there are other API resources. Most of them are for the read only part of the automation which is great for me

Those I collected so far are

  1. https://www.covalenthq.com/
  2. https://thegraph.com/en/
  3. https://dexscreener.com/

So it seems that I am covered on the read only part. If only I can automate some wallet that'll be great. It seems to be what Nethereum do.

It seems that if we paste an EVM code we will be able to create some functions. Functions that look like

And then use some plugin to create ac# function that interact with some ethereum node.

For example,

在此处输入图像描述

So something automatically create SetRequestAndWaitForReceiptAsync

I'll start from there.

Anyway, I found that dexscreener will solve the read part of my plan.

For example,

https://api.dexscreener.com/latest/dex/pairs/fantom/0x2dc234dbfc085ddbc36a6eacc061d7333cd397b0

Shows

{"schemaVersion":"1.0.0","pairs":[{"chainId":"fantom","dexId":"spookyswap","url":"https://dexscreener.com/fantom/0x2dc234dbfc085ddbc36a6eacc061d7333cd397b0","pairAddress":"0x2DC234DbfC085DdbC36a6EACC061D7333Cd397b0","baseToken":{"address":"0x8a41f13a4FaE75ca88B1ee726ee9D52B148b0498","name":"Ripae","symbol":"PAE"},"quoteToken":{"symbol":"WFTM"},"priceNative":"122.14","priceUsd":"43.87","txns":{"h24":{"buys":997,"sells":2003},"h6":{"buys":212,"sells":479},"h1":{"buys":51,"sells":101},"m5":{"buys":0,"sells":9}},"volume":{"h24":591159.12,"h6":124512.92,"h1":31047.84,"m5":351.69},"priceChange":{"h24":-16.13,"h6":0.2,"h1":1.31,"m5":0.36},"liquidity":{"usd":409095.69760772487,"base":4652.47,"quote":569418},"fdv":26644339.03,"pairCreatedAt":1643886747000}],"pair":{"chainId":"fantom","dexId":"spookyswap","url":"https://dexscreener.com/fantom/0x2dc234dbfc085ddbc36a6eacc061d7333cd397b0","pairAddress":"0x2DC234DbfC085DdbC36a6EACC061D7333Cd397b0","baseToken":{"address":"0x8a41f13a4FaE75ca88B1ee726ee9D52B148b0498","name":"Ripae","symbol":"PAE"},"quoteToken":{"symbol":"WFTM"},"priceNative":"122.14","priceUsd":"43.87","txns":{"h24":{"buys":997,"sells":2003},"h6":{"buys":212,"sells":479},"h1":{"buys":51,"sells":101},"m5":{"buys":0,"sells":9}},"volume":{"h24":591159.12,"h6":124512.92,"h1":31047.84,"m5":351.69},"priceChange":{"h24":-16.13,"h6":0.2,"h1":1.31,"m5":0.36},"liquidity":{"usd":409095.69760772487,"base":4652.47,"quote":569418},"fdv":26644339.03,"pairCreatedAt":1643886747000}}

Which is what I need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM