justdmitry / tonlib.net Goto Github PK
View Code? Open in Web Editor NEWtonlibjson wrapper for .NET
License: MIT License
tonlibjson wrapper for .NET
License: MIT License
Please support of TON storage-daemon
Thanks.
First of all, thank you for creating a library for C#.
It would be great to be able to work with private keys without importing them into the storage.
Like here
https://github.com/xssnick/tonutils-go/blob/master/ton/wallet/wallet.go#L430
Hello! Thank you for your excellent library.
I'm trying to pull Jetton Master data, I am using the reference specification to assist me: https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md#specification
I have the following example:
First, I pull the get_jetton_data
:
Info smcRouter = await _ton.TrySmcLoad(Address);
var result = await _ton.SmcRunGetMethod(smcRouter.Id, new MethodIdName("get_jetton_data"));
var stack = result.Stack.ToArray();
var totalSupply = stack[0].ToBigInteger();
var mintable = stack[1].ToBigInteger();
var adminAddress = stack[2].GetAddress();
var metadataCell = stack[3].ToBoc().RootCells[0];
Then, I want to deserialize the metadata cell to it's components, however I'm struggling to see how to do this.
Initially I want to decompose it to first grab the Decimals, where the case is there are onchain properties for, I am using this jUSDT
token to test this:
https://tonscan.com/EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA?tab=methods
This reports the following for jetton_content
:
{
"type": "onchain",
"data": {
"image": "https://bridge.ton.org/token/1/0xdac17f958d2ee523a2206206994597c13d831ec7.png",
"uri": "https://bridge.ton.org/token/1/0xdac17f958d2ee523a2206206994597c13d831ec7.json",
"decimals": "6"
}
}
Now I want to deserialize my metadataCell
into a dictionary for me to extract the above representation, but I can't see how to do this. I can call LoadDict on the cell, which it should be, I get back a Cell.
I then use the specification referenced for Token Data, that the key should be a SHA256 as a string, and the value should be serialized later (so I pull the Slice). This isn't working for me and fails to deserialize the dictionary (No dictionary found
).
public static Metadata ParseFromCell(Cell cell)
{
const int OnchainContent = 0;
const int OffchainContent = 1;
var slice = cell.BeginRead();
var contentType = slice.LoadByte();
if(contentType != OnchainContent)
throw new Exception("Unsupported representation type");
var dict = slice.LoadDict();
var output = dict.BeginRead().LoadAndParseDict<string, TonLibDotNet.Cells.Slice>(
256,
x => x.LoadString()!,
x => x,
new StringComparer());
return new Metadata();
}
Do you have any suggestions on how I can get this deserialized correctly, or at least get a reference to a Dictionary<TKey,TValue>
for me to take this further?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.