tronscan / tronscan-node-client Goto Github PK
View Code? Open in Web Editor NEWNode Client for Tronscan
Home Page: https://api.tronscan.org
License: GNU Lesser General Public License v3.0
Node Client for Tronscan
Home Page: https://api.tronscan.org
License: GNU Lesser General Public License v3.0
I was even trying to work with tronix.js but not able createTransaction and send transaction.Getting this...
The deserializeTransaction is : 147,246,,,184,59,183,243,185,12,202,84,,,,1537516374000,,,1,type.googleapis.com/protocol.TransferContract,10,21,65,157,171,82,157,66,169,49,246,215,142,180,5,69,122,0,182,91,217,49,11,18,21,65,186,138,235,140,169,49,133,133,183,210,87,106,117,203,8,214,38,37,212,117,24,160,141,6,170,73,82,110,241,56,195,78,119,204,241,30,228,5,103,221,15,18,88,172,73,226,157,17,32,198,209,155,44,186,122,134,92,16,58,175,176,75,95,39,16,49,213,19,223,145,205,89,93,89,215,140,38,187,154,127,81,116,155,5,195,128,38,4,1,,,
this is transaction id[object Object]
My function is this ..
async function run() {
// Create and broadcast transaction
const transaction = await client.createTransaction(
'1e29bcdc573ec404b25ea5ec9f66b2f6f39c596f350dca5dfadb9f43099f578d',
'TUiAwy29KbwqbmjccHSyWHa5fUFiW8o5Xn',
'TZG7vRbLKMLV9cpKh4McsYtrWVdZ8kQAp2',
1,
);
console.log("this is transaction id isssssssssssssss :" +transaction); // result
}
run();
What wrong i am doing not getting .
This looks totally different from other coins...
Have you plans to support typescript?
Now i'm activity work with tron and want to use this library but my app in typescript fully.
If i add support typescript and sent pull request you accept that?
In javascript, Number.MAX_SAFE_INTEGER is 9007199254740991, or 0x1fffffffffffff in hex, so you can not represent a big number to 8 bytes array correctly in this method.If the input is large than Number.MAX_SAFE_INTEGER, the result is incorrect.
tronscan-node-client/src/client/http.js
Line 12 in 524235b
Is there any plan to support Stake 2.0?
`import {Client} from "@tronscanteam/apiclients";
const client = new Client('https://api.tronscan.org');
let getMarkets = await client.getMarkets()
console.log(getMarkets)`
i got this error
data: {
servlet: 'org.eclipse.jetty.servlet.ServletHandler$Default404Servlet-6419a0e1',
message: 'Not Found',
url: '/api/market/markets',
status: '404'
}
when i try to send trx amount 1, it sent 0.000001 TRX not 1 TRX.
so i tried to send 1000000 trx, i sent 1 TRX.
except TRX other tokens has no issue.
thanks.
When we try to require
@tronscan/client/src/utils/tronWeb.js, we get syntax errors on Node.js. It turns out that the same file can't contain ES6 export
statements and CommonJS require
statements, or various build tools will break.
We are currently using patch-package to patch @tronscan/[email protected]
. Here is the diff we are using:
diff --git a/node_modules/@tronscan/client/src/utils/tronWeb.js b/node_modules/@tronscan/client/src/utils/tronWeb.js
index 6b1bc38..3f48a11 100644
--- a/node_modules/@tronscan/client/src/utils/tronWeb.js
+++ b/node_modules/@tronscan/client/src/utils/tronWeb.js
@@ -25,7 +25,7 @@ const {
const fromHexString = hexString =>
new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
-export function transactionJsonToProtoBuf(transaction) {
+function transactionJsonToProtoBuf(transaction) {
const rawData = transaction["raw_data"];
const contractJson = rawData.contract[0];
const transactionObj = contractJsonToProtobuf(contractJson);
@@ -52,7 +52,7 @@ export function transactionJsonToProtoBuf(transaction) {
return transactionObj;
}
-export function contractJsonToProtobuf(contract) {
+function contractJsonToProtobuf(contract) {
const value = contract.parameter.value;
switch (contract.type) {
@@ -365,3 +365,8 @@ export function contractJsonToProtobuf(contract) {
}
}
+
+module.exports = {
+ transactionJsonToProtoBuf,
+ contractJsonToProtobuf
+};
Of course, we would love to get this fix upstream.
This issue body was partially generated by patch-package.
Hello,
i m trying to send trx to a text wallet but i have issue. Here is my code:
`
var tronscan = require("@tronscan/client");
var client = new tronscan.Client();
var privatekey = "my privkey";
client.apiUrl = 'https://api.tronscan.org';
var signer = client.getSigner(privatekey);
client.setSigner(signer);
async function test() {
var from = "TCoCwAuNFAfY2QR8tb8LyuapEztpyauSuJ";
var to = "TX4xiCK4aS84vmTL9CWK141EFCg53wTtmY";
var amount = 1;
var account = await client.getAccountByAddress(from);
var token = await client.createToken(account);
var t1 = await client.send(token, from, to, amount);
console.log(t1)
}
test()
`
Help would be appreciate. Regards
For php do not plan to implement, tron client?
JsPbCodeGenerator generates this thing
var global = Function('return this')();
in src/protocol/api/api_pb.js
which results errors because chrome extensions disallow code evaluation. The workaround could be this patch-package to patch @tronscan/[email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/@tronscan/client/src/protocol/api/api_pb.js b/node_modules/@tronscan/client/src/protocol/api/api_pb.js
index 3052560..2ea211e 100644
--- a/node_modules/@tronscan/client/src/protocol/api/api_pb.js
+++ b/node_modules/@tronscan/client/src/protocol/api/api_pb.js
@@ -9,7 +9,7 @@
var jspb = require('google-protobuf');
var goog = jspb;
-var global = Function('return this')();
+var global = globalThis;
var core_Tron_pb = require('../core/Tron_pb.js');
var core_Contract_pb = require('../core/Contract_pb.js');
diff --git a/node_modules/@tronscan/client/src/protocol/core/Contract_pb.js b/node_modules/@tronscan/client/src/protocol/core/Contract_pb.js
index a31ef63..a6b578f 100644
--- a/node_modules/@tronscan/client/src/protocol/core/Contract_pb.js
+++ b/node_modules/@tronscan/client/src/protocol/core/Contract_pb.js
@@ -9,7 +9,7 @@
var jspb = require('google-protobuf');
var goog = jspb;
-var global = Function('return this')();
+var global = globalThis;
var core_Tron_pb = require('../core/Tron_pb.js');
goog.exportSymbol('proto.protocol.AccountCreateContract', null, global);
diff --git a/node_modules/@tronscan/client/src/protocol/core/Discover_pb.js b/node_modules/@tronscan/client/src/protocol/core/Discover_pb.js
index 2f1745d..6e5723c 100644
--- a/node_modules/@tronscan/client/src/protocol/core/Discover_pb.js
+++ b/node_modules/@tronscan/client/src/protocol/core/Discover_pb.js
@@ -9,7 +9,7 @@
var jspb = require('google-protobuf');
var goog = jspb;
-var global = Function('return this')();
+var global = globalThis;
goog.exportSymbol('proto.protocol.BackupMessage', null, global);
goog.exportSymbol('proto.protocol.Endpoint', null, global);
diff --git a/node_modules/@tronscan/client/src/protocol/core/TronInventoryItems_pb.js b/node_modules/@tronscan/client/src/protocol/core/TronInventoryItems_pb.js
index d2744d7..42cdb6c 100644
--- a/node_modules/@tronscan/client/src/protocol/core/TronInventoryItems_pb.js
+++ b/node_modules/@tronscan/client/src/protocol/core/TronInventoryItems_pb.js
@@ -9,7 +9,7 @@
var jspb = require('google-protobuf');
var goog = jspb;
-var global = Function('return this')();
+var global = globalThis;
goog.exportSymbol('proto.protocol.InventoryItems', null, global);
diff --git a/node_modules/@tronscan/client/src/protocol/core/Tron_pb.js b/node_modules/@tronscan/client/src/protocol/core/Tron_pb.js
index eb92447..60822cb 100644
--- a/node_modules/@tronscan/client/src/protocol/core/Tron_pb.js
+++ b/node_modules/@tronscan/client/src/protocol/core/Tron_pb.js
@@ -9,7 +9,7 @@
var jspb = require('google-protobuf');
var goog = jspb;
-var global = Function('return this')();
+var global = globalThis;
var google_protobuf_any_pb = require('google-protobuf/google/protobuf/any_pb.js');
var core_Discover_pb = require('../core/Discover_pb.js');
This issue body was partially generated by patch-package.
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.