Coder Social home page Coder Social logo

everx-labs / ton-client-node-js Goto Github PK

View Code? Open in Web Editor NEW
22.0 19.0 0.0 156 KB

TON Javascript API for Node.js

License: Apache License 2.0

JavaScript 95.03% Shell 4.97%
sdk blockchain telegram-open-network api graphql web3js lite-client ton-sdk web3 hacktoberfest

ton-client-node-js's Introduction

TON Javascript Node.js SDK

npm publish

Community links:

Chat on Telegram Gitter

Documentation

GraphQL API and SDK documentation

The JavaScript SDK implements the client-side libraries used by applications working with TON OS GraphQL API.
This package supports web (browser), mobile-web, and server (Node.js) clients.

Common Javascript SDK is distributed via npm package.

Attention! Because the JS library uses pre-compiled core sdk rust library, you need to install it via platform-dependable node-js package that will automatically install common js package + download and link pre-compiled rust core to your project:

npm install ton-client-node-js

To get started using TON Javascript SDK, see Add SDK to your Application.


Copyright 2018-2020 TON DEV SOLUTIONS LTD.

ton-client-node-js's People

Contributors

alexeyvavilin avatar atomxy avatar diserere avatar elasticlove1 avatar futurizt avatar g9d avatar joydark avatar melsomino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ton-client-node-js's Issues

Error during call of client.contracts.run

Here is traceback of this error:
TypeError: Cannot read property 'startSpan' of undefined
at TONClient._callee11$ (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\ton-client-js\dist\TONClient.js:627:43)
at tryCatch (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\regenerator-runtime\runtime.js:63:40)
at Generator.invoke [as _invoke] (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\regenerator-runtime\runtime.js:293:22)
at Generator.next (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\regenerator-runtime\runtime.js:118:21)
at asyncGeneratorStep (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\ton-client-js\dist\TONClient.js:42:103)
at _next (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\ton-client-js\dist\TONClient.js:44:194)
at C:\Users\User\Documents\github\SmartContractsForTON\node_modules\ton-client-js\dist\TONClient.js:44:364
at new Promise ()
at TONClient. (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\ton-client-js\dist\TONClient.js:44:97)
at TONClient.trace (C:\Users\User\Documents\github\SmartContractsForTON\node_modules\ton-client-js\dist\TONClient.js:664:23)

Function call paramters:
{
address: validContractAddress,
abi: contractAbi,
functionName: contractFunctionName,
input: {contractFunctionInput},
keyPair: keysCreatedFromSeedPhrase
}

Client was created by:
let client = await new TONClient({servers: ['https://net.ton.dev']});

Used node version:
12.18.4

Can not find tonclient.node when it exists

$ node index.js
Error: Cannot find module '/home/tiger/.tonlabs/binaries/0_16_0/tonclient.node'

This message is not entirely accurate and to some extent confusing, because I see this file exists (next to the index.js). The problem is that the original error message was silently swallowed here: https://github.com/tonlabs/ton-client-node-js/blob/master/index.js#L17

I can see the real cause if I add console.log in the next line:
Error: /lib64/libc.so.6: version GLIBC_2.18 not found (required by /home/tiger/bin/node-v10.16.3-linux-x64/lib/node_modules/ton-dev-cli/node_modules/ton-client-node-js/tonclient.node)

That's true, I use CentOS 7.5 with old enough GLIBC

[tiger@vm-8f40bed7 ~]$ ldd --version
ldd (GNU libc) 2.17

This situation is not very rare, so displaying the original error message will save enough time to find the cause.

Error Deploying contracts

Hello !

I am doing the SDK tutorial with the Node JS library.

at the stage of Deploying contracts I find the following error

{source: 'sdk',    code: 2004,    message:     'Invalid address [SizeError]: 0: 841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94'}

Can you help me ?

This mi code

const { TONClient } = require('ton-client-node-js');

// Define contract package

const HelloContract = require('./helloContract');

// Define keys for our contract

const helloKeys = {
public: '55d7bab463a6a3ef5e03bb5f975836ddfb589b9ccb00329be7da8ea981c5268a',
secret: 'de93a97c7103c2d44e47972265cfdfe266fd28c8cadc4875804ee9f57cf786d6',
};

const giverAddress = '0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94';
const giverAbi =
{
"ABI version": 0,
"functions": [
{
"name": "constructor",
"inputs": [],
"outputs": []
},
{
"name": "sendGrams",
"inputs": [
{"name":"dest","type":"address"},
{"name":"amount","type":"uint64"}
],
"outputs": []
}
],
"events": [],
"data": []
};

(async () => {
try {
const client = new TONClient();
client.config.setData({
servers: ['http://0.0.0.0']
});
await client.setup();
await main(client);
console.log('Hello TON Done');
process.exit(0);
} catch (error) {
console.error(error);
}
})();

async function get_grams_from_giver(client, account) {
const { contracts, queries } = client;
const result = await contracts.run({
address: giverAddress,
functionName: 'sendGrams',
abi: giverAbi,
input: {
dest: account,
amount: 5000000000
},
keyPair: null,
});

const wait = await queries.accounts.waitFor(
    {
        id: { eq: account },
        balance: { gt: "0" }
    },
	'id balance'
);

};

async function main(client) {
// <<<<< La siguiente sentencia arroja el error >>>>>
const futureHelloAddress = (await client.contracts.createDeployMessage({
package: HelloContract.package,
constructorParams: {},
keyPair: helloKeys,
})).address;

console.log(`Future address of the contract will be: ${futureHelloAddress}`);

await get_grams_from_giver(client, futureHelloAddress);
console.log(`Grams were transfered from giver to ${futureHelloAddress}`);

const helloAddress = (await client.contracts.deploy({
    package: HelloContract.package,
    constructorParams: {},
    keyPair: helloKeys,
})).address;
console.log(`Hello contract was deployed at address: ${helloAddress});

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.