I wanna code using nethereum. I download nuget and make this simple program
It works.
Private Async Function doSomething() As Task
Dim privatekey = System.IO.File.ReadAllText("privatekey.txt")
'Dim publickey = "0x898568c58466957bedaE0e2A2457beb158a150de" ''
Dim destination = "0x7fD0Ec4d9908A712852d32d110839Fc1A9Ce55d5"
Dim rpcURL = "https://rpc.ftm.tools" ' where should I put this
Dim chainID = 250 'Where should I put this?
Dim account = New Nethereum.Web3.Accounts.Account(privatekey, chainID)
Dim web3Obj = New Nethereum.Web3.Web3(account, rpcURL)
Dim transManager = web3Obj.TransactionManager
transManager.UseLegacyAsDefault = True
'Dim amount = Nethereum.Web3.Web3.Convert.ToWei(0.1)
Dim balance = Await web3Obj.Eth.GetBalance.SendRequestAsync(account.Address)
Dim EtherBalance = Nethereum.Web3.Web3.Convert.FromWei(balance.Value) 'I got the correct value here
Dim transInput = New Nethereum.RPC.Eth.DTOs.TransactionInput
transInput.From = account.Address
transInput.To = destination
Dim estimategas = Await web3Obj.TransactionManager.EstimateGasAsync(transInput)
Dim estimategasbiginteger = estimategas.Value
If estimategasbiginteger > 100000 Then
Return
End If
Dim result = Await web3Obj.Eth.GetEtherTransferService.TransferEtherAsync(destination, 0.1D,, estimategas)
End Function
However, I cannot step into nethereum code. For example, I have no idea what's going on in web3Obj.TransactionManager.EstimateGasAsync(transInput)
Trying to read documentation is confusing. I thought I'll just go through the code.
I downloaded nethereum from github. I have never done something like this successfully.
So I download the whole source code from
https://github.com/Nethereum/Nethereum
I tried to add some of project files to my solution and compile. My test program is in vb.net by the way.
I got lots of errors. Lots of the errors revolve around wrong target framework. For example, nethereum support net framework 3.5. In fact, Juan Blanco seem to go the extra mile adding namespaces and some functions available on higher .net framework but not on earlier framework.
So?
I twinkle a bit and it seems that the solution is to make all project target .net 6.
I look at project files and they tend to contain this thing
<TargetFrameworks>$(DefaultFrameworksUnitySupport)</TargetFrameworks>
So, $(DefaultFrameworksUnitySupport) must have been defined somewhere and I will just change that to net6.0-windows
After more surfing I found that I need to change content of Framework.props
I added these 2 lines and remove many conditional stuffs.
<DefaultFrameworks>net6.0-windows</DefaultFrameworks>
<DefaultFrameworksUnitySupport>net6.0-windows</DefaultFrameworksUnitySupport>
It seems working. Most projects look like they are targeting net6.0
I tried to compile and I got this error
Severity Code Description Project File Line Suppression State Error NU1201 Project Nethereum.Hex is not compatible with net35 (.NETFramework,Version=v3.5). Project Nethereum.Hex supports: net6.0-windows7.0 (.NETCoreApp,Version=v6.0) Nethereum.Model C:\Users\hello\Dropbox\vb.net\Nethereum-master\src\Nethereum.Model\Nethereum.Model.csproj 1
So, basically Nethereum.Model and Nethereum.Hex should both aim at net6.0-windows7.0
In fact, the error code themselves say that Nethereum.Hex target net6.0-windows7.0
It seems that Nethereum.Model that target Nethereum.Hex still target 3.5 or something. Which is weird. I already changed that remember?
They both contain
<TargetFrameworks>$(DefaultFrameworksUnitySupport)</TargetFrameworks>
So they both should target net6.0-windows7.0
After all it's the same variable. I just set that same variable to net6.0-windows7.0.
The only difference I can think of is Nethereum.Hex is added explicitly in my sollution but Nethereum.Model is not.
So what went wrong?
Basically this is my solution file
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32526.322
MinimumVisualStudioVersion = 10.0.40219.1
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "testapp", "testapp\testapp.vbproj", "{617292CC-896D-407E-97A5-CB00F7137B3F}"
ProjectSection(ProjectDependencies) = postProject
{12605CC4-C9AE-4C04-889E-7905BCDB80A9} = {12605CC4-C9AE-4C04-889E-7905BCDB80A9}
{232B09D7-F40C-4DB7-A737-ADFA0C8D83AA} = {232B09D7-F40C-4DB7-A737-ADFA0C8D83AA}
{8AD3EC08-4FF1-4D38-9FCF-067CD584C390} = {8AD3EC08-4FF1-4D38-9FCF-067CD584C390}
{AED8F43B-2345-4B61-8D0A-CF925DB4A6F8} = {AED8F43B-2345-4B61-8D0A-CF925DB4A6F8}
{BD1872DC-5C24-45BF-8090-8C7D218409CA} = {BD1872DC-5C24-45BF-8090-8C7D218409CA}
{E85B97A9-A5BF-46EB-992D-A1053AFF24A3} = {E85B97A9-A5BF-46EB-992D-A1053AFF24A3}
{EFDE4E30-889C-4B64-AD53-A70C5BCB070F} = {EFDE4E30-889C-4B64-AD53-A70C5BCB070F}
{F3EA00A4-8785-42F2-A393-E9AB3BB3682A} = {F3EA00A4-8785-42F2-A393-E9AB3BB3682A}
{FC69EBFB-2007-4EB2-9E4C-B48E0E6BD072} = {FC69EBFB-2007-4EB2-9E4C-B48E0E6BD072}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.Web3", "..\Nethereum-master\src\Nethereum.Web3\Nethereum.Web3.csproj", "{232B09D7-F40C-4DB7-A737-ADFA0C8D83AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.BlockchainProcessing", "..\Nethereum-master\src\Nethereum.BlockchainProcessing\Nethereum.BlockchainProcessing.csproj", "{EFDE4E30-889C-4B64-AD53-A70C5BCB070F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.Contracts", "..\Nethereum-master\src\Nethereum.Contracts\Nethereum.Contracts.csproj", "{BD1872DC-5C24-45BF-8090-8C7D218409CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.RPC", "..\Nethereum-master\src\Nethereum.RPC\Nethereum.RPC.csproj", "{AED8F43B-2345-4B61-8D0A-CF925DB4A6F8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.JsonRpc.Client", "..\Nethereum-master\src\Nethereum.JsonRpc.Client\Nethereum.JsonRpc.Client.csproj", "{E85B97A9-A5BF-46EB-992D-A1053AFF24A3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.Util", "..\Nethereum-master\src\Nethereum.Util\Nethereum.Util.csproj", "{FC69EBFB-2007-4EB2-9E4C-B48E0E6BD072}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.Signer", "..\Nethereum-master\src\Nethereum.Signer\Nethereum.Signer.csproj", "{8AD3EC08-4FF1-4D38-9FCF-067CD584C390}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.ABI", "..\Nethereum-master\src\Nethereum.ABI\Nethereum.ABI.csproj", "{12605CC4-C9AE-4C04-889E-7905BCDB80A9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nethereum.Hex", "..\Nethereum-master\src\Nethereum.Hex\Nethereum.Hex.csproj", "{F3EA00A4-8785-42F2-A393-E9AB3BB3682A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{617292CC-896D-407E-97A5-CB00F7137B3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{617292CC-896D-407E-97A5-CB00F7137B3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{617292CC-896D-407E-97A5-CB00F7137B3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{617292CC-896D-407E-97A5-CB00F7137B3F}.Release|Any CPU.Build.0 = Release|Any CPU
{232B09D7-F40C-4DB7-A737-ADFA0C8D83AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{232B09D7-F40C-4DB7-A737-ADFA0C8D83AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{232B09D7-F40C-4DB7-A737-ADFA0C8D83AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{232B09D7-F40C-4DB7-A737-ADFA0C8D83AA}.Release|Any CPU.Build.0 = Release|Any CPU
{EFDE4E30-889C-4B64-AD53-A70C5BCB070F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFDE4E30-889C-4B64-AD53-A70C5BCB070F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFDE4E30-889C-4B64-AD53-A70C5BCB070F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFDE4E30-889C-4B64-AD53-A70C5BCB070F}.Release|Any CPU.Build.0 = Release|Any CPU
{BD1872DC-5C24-45BF-8090-8C7D218409CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD1872DC-5C24-45BF-8090-8C7D218409CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD1872DC-5C24-45BF-8090-8C7D218409CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD1872DC-5C24-45BF-8090-8C7D218409CA}.Release|Any CPU.Build.0 = Release|Any CPU
{AED8F43B-2345-4B61-8D0A-CF925DB4A6F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AED8F43B-2345-4B61-8D0A-CF925DB4A6F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AED8F43B-2345-4B61-8D0A-CF925DB4A6F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AED8F43B-2345-4B61-8D0A-CF925DB4A6F8}.Release|Any CPU.Build.0 = Release|Any CPU
{E85B97A9-A5BF-46EB-992D-A1053AFF24A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E85B97A9-A5BF-46EB-992D-A1053AFF24A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E85B97A9-A5BF-46EB-992D-A1053AFF24A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E85B97A9-A5BF-46EB-992D-A1053AFF24A3}.Release|Any CPU.Build.0 = Release|Any CPU
{FC69EBFB-2007-4EB2-9E4C-B48E0E6BD072}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC69EBFB-2007-4EB2-9E4C-B48E0E6BD072}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC69EBFB-2007-4EB2-9E4C-B48E0E6BD072}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC69EBFB-2007-4EB2-9E4C-B48E0E6BD072}.Release|Any CPU.Build.0 = Release|Any CPU
{8AD3EC08-4FF1-4D38-9FCF-067CD584C390}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AD3EC08-4FF1-4D38-9FCF-067CD584C390}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AD3EC08-4FF1-4D38-9FCF-067CD584C390}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AD3EC08-4FF1-4D38-9FCF-067CD584C390}.Release|Any CPU.Build.0 = Release|Any CPU
{12605CC4-C9AE-4C04-889E-7905BCDB80A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12605CC4-C9AE-4C04-889E-7905BCDB80A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12605CC4-C9AE-4C04-889E-7905BCDB80A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12605CC4-C9AE-4C04-889E-7905BCDB80A9}.Release|Any CPU.Build.0 = Release|Any CPU
{F3EA00A4-8785-42F2-A393-E9AB3BB3682A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3EA00A4-8785-42F2-A393-E9AB3BB3682A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3EA00A4-8785-42F2-A393-E9AB3BB3682A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3EA00A4-8785-42F2-A393-E9AB3BB3682A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {84CEFC11-357A-457D-8873-6F0590974D73}
EndGlobalSection
EndGlobal
Should I just add more projects or what?