C
C#•2y ago
slotsclassic

Error

Anyone know why this is happening? im a bit lost here. "System.NullReferenceException: 'The object reference is not set to an instance of an object.'" https://gyazo.com/53783b0f627a112e1ab2e852926826af
Gyazo
Gyazo
28 Replies
Thinker
Thinker•2y ago
addressInfo or ChainStats is null So it appears that there's something wrong with the JSON deserialization Can you show the structure of AddressInfo? And what does the JSON string look like?
slotsclassic
slotsclassicOP•2y ago
wdym json string look like?
public class AddressInfo
{
public string Address { get; set; }
public ChainStats ChainStats { get; set; }
}
public class AddressInfo
{
public string Address { get; set; }
public ChainStats ChainStats { get; set; }
}
Denis
Denis•2y ago
You are deserializing a string. It's value is in the format of json . Copy the value of the string you are deserializing And paste it here
x0rld 👻 🎃
the json should look like that in json variable
{
"address": ""
"ChainStats": {..}
}
{
"address": ""
"ChainStats": {..}
}
Denis
Denis•2y ago
The value of the json variable at line 87 to be specific
slotsclassic
slotsclassicOP•2y ago
uhm weird shit i didnt touch anything in the code, but it works now how
slotsclassic
slotsclassicOP•2y ago
slotsclassic
slotsclassicOP•2y ago
tf why it just work out of thin air
Denis
Denis•2y ago
Connection issue?
slotsclassic
slotsclassicOP•2y ago
all i added since then was a "with balance capture" put into my if(balance > 0) withBal++.ToString();
x0rld 👻 🎃
don't do a ++ and another operation ( ToString) at same time it's a really make it super harder to read
Thinker
Thinker•2y ago
Could be that, since you're calling an external API, that the API just happened to return null or unauthorized or something at that point
slotsclassic
slotsclassicOP•2y ago
thats always how i capture int values, how would you be doing it? so an error from the API and not my code
Thinker
Thinker•2y ago
perhaps
x0rld 👻 🎃
you want to have the string before or after adding +1 to your variable ?
Thinker
Thinker•2y ago
You should probably do a null check after the AddressInfo addressInfo = ... line.
x0rld 👻 🎃
I just say do that instead of one line it it's much easier to read
withBal++;
withBal.ToString();
withBal++;
withBal.ToString();
Denis
Denis•2y ago
Less lines != Good code
x0rld 👻 🎃
btw you could use directly this method to deserialize instead of getting string, then read it, then deserialize it https://learn.microsoft.com/en-us/dotnet/api/system.net.http.json.httpclientjsonextensions.getfromjsonasync?view=net-7.0
slotsclassic
slotsclassicOP•2y ago
well, shits fixed now. Now i just have to add proxy support so i wont get timeout
Buddy
Buddy•2y ago
What are you making?
slotsclassic
slotsclassicOP•2y ago
tbh project is useless, but a good practise thing its just gens a mnemonic and checks for the balance through an API
Buddy
Buddy•2y ago
eh, ok lol
slotsclassic
slotsclassicOP•2y ago
but the chance of actually finding a lost crypto wallet with it is 0.00000000000000000000000000000000000000684%
Buddy
Buddy•2y ago
So what does it actually achieve?
slotsclassic
slotsclassicOP•2y ago
My practise skills with web requests only tbh nothing else practise using loops
Scratch
Scratch•2y ago
!ban @Degenerate developing hacking tools
Want results from more Discord servers?
Add your server