Web3.m
Version 1.0.0 (7,43 KB) von
Emil Skoglund
This is a starter pack for interacting with the ethereum blockchain from matlab.
To use thes functions you need to first set up your python environment and get the necessary API keys for Infura end etherscan.
Python environment:
Download miniconda and from the cmd do "pip install web3".
Then use the following matlab command to set the path to your miniconda python envronment,
pyenv("Version","C:\Users\[Emil]\miniconda3\python.exe")
Infura:
Go to https://www.infura.io/ and create an account and retrieve your personal infura URL. It should look something like this: https://mainnet.infura.io/v3/60xx82859xx54x608x7x83x0x70xx387
Etherscan:
Go to https://docs.etherscan.io/getting-started/creating-an-account and follow the instructions to create an account and retrieve your API key. It should look something like this: XXCXYT8X76XEZJXXXXXUP8XXX9XXXXQXX
Set up a wallet:
Download metamask browser extension and create a wallet unless you already have one. Then open the wallet and retrieve the address and key.
Address should look something like this: 0x830BBe006X2Xd0a4c815X9xBx193515x1c4B06xx
Key should look something like this: 0x817065cxxxde3778x72d3705xxxxx603a12363x951cd8346xxx27615f7xxxfxx
Then, go to the functions and replace the infura URL and etherscan key where they are used.
In the getGasPrice.m function is where you need to replace the etherscan key
The other functions, amountOut, approve, swapTokenForToken you need to replace the infura URL
Don't touch the Uniswap.py unless you want to make more functions. There are some functions in there that do not have a corresponding matlab function, and if you want to create those then follow the example of the already existing ones.
Sorry for the inconvinence of having to replace the keys for every function one by one. By the next update they will be loaded from a single file instead.
Zitieren als
Emil Skoglund (2024). Web3.m (https://www.mathworks.com/matlabcentral/fileexchange/122822-web3-m), MATLAB Central File Exchange. Abgerufen .
Kompatibilität der MATLAB-Version
Erstellt mit
R2022b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.0.0 |