tronprotocol / java-tron

Java implementation of the Tron whitepaper
GNU Lesser General Public License v3.0
3.64k stars 1.36k forks source link

I built a tron ​​Private Chain, created a Trc20 token, deployed it, and checked the balance, but constant_result is empty. #5889

Open mbc3377 opened 1 week ago

mbc3377 commented 1 week ago

I built a tron ​​Private Chain, created a trc20 token with TronBox, and run tronbox migrate --reset.

Using network 'development'.

Running migration: 1_initial_migration.js Replacing Migrations... Migrations: (base58)TC9KHf298fjf5wnXcVVDbES5bR4pVa47mS (hex) 4117d9a89a8cfe459310ea718200eb4d122ab1b343 Saving successful migration to network... Saving artifacts... Running migration: 2_deploy_contracts.js Replacing Token... Token: (base58) TSJZHJ5LQTdEs81EwjpVnf5uFQmGu9Q31x (hex) 41b32ad83b1216c01a16a5aebceeb38465675eb206 Saving successful migration to network... Saving artifacts...

When you check the balance through tronweb, the constant result value is empty as shown below.

{ result: { result: true }, constant_result: [ '' ], transaction: { ret: [ {} ], visible: false; txID: '0ce85318b89210efcc0283dd36bbdbb08bdbfca13feb9bc6ad8dedec3d4a4d6a', raw_data: { contract: [Array], ref_block_bytes: '0ad1', ref_block_hash: '1affa3e094f99143', expiration: 1719551661000, timestamp: 1719551602763 }, raw_data_hex: '0a020ad122081affa3e094f9914340c8a790ea85325a6d081f12690a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5 4726967676572536d617274436f6e747261637412340a1541cc83350e01a0a8fba6a548e8d08c97646715de921215417e6538c3b333a55f03147972057bfe 30be1ebc33220418160ddd70cbe08cea8532' } }

Return with constant_result: [ '' ], like this I kept changing the java-tron version and tested it, but the same thing happened.

If you deploy with TEST net (https://nile.trongrid.io/), it processes normally.


This is the config file I am using.

net { type = mainnet }

storage {

db.version = 2, db.engine = "LEVELDB", db.directory = "database", index.directory = "index",

properties = [ // { // name = "account", // path = "storage_directory_test", // createIfMissing = true, // paranoidChecks = true, // verifyChecksums = true, // compressionType = 1, // compressed with snappy // blockSize = 4096, // 4 KB = 4 1024 B // writeBufferSize = 10485760, // 10 MB = 10 1024 1024 B // cacheSize = 10485760, // 10 MB = 10 1024 1024 B // maxOpenFiles = 100 // }, // { // name = "account-index", // path = "storage_directory_test", // createIfMissing = true, // paranoidChecks = true, // verifyChecksums = true, // compressionType = 1, // compressed with snappy // blockSize = 4096, // 4 KB = 4 1024 B // writeBufferSize = 10485760, // 10 MB = 10 1024 1024 B // cacheSize = 10485760, // 10 MB = 10 1024 1024 B // maxOpenFiles = 100 // }, ]

}

node.discovery = { enable = true # you should set this entry value with true if you want your node can be discovered by other node. persist = true # this entry is used to determined to whether storing the peers in the database or not. external.ip = 127.0.0.1 }

node.backup { port = 10001 priority = 8 members = [ ] }

node {

trustNode = "127.0.0.1:50051"

walletExtensionApi = true

listen.port = 16666

connection.timeout = 2

tcpNettyWorkThreadNum = 0

udpNettyWorkThreadNum = 1

maxActiveNodes = 30

maxActiveNodesWithSameIp = 2

minParticipationRate = 0

disconnectNumberFactor = 0.4 maxConnectNumberFactor = 0.8 receiveTcpMinDataLength = 2048 isOpenFullTcpDisconnect = true

p2p { version = 1 # 11111: mainnet; 20180622: testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net. }

active = [ ]

passive = [ ]

http { fullNodePort = 16667 solidityPort = 16668 }

rpc { port = 16669 maxConnectionIdleInMillis = 60000 minEffectiveConnection = 0 }

dns {

treeUrls = [

]

} }

seed.node = {

ip.list = [ ] }

genesis.block = { assets = [ { accountName = "Zion" accountType = "AssetIssue" address = "TUca2dayrKr1ELWLaY7bLkVxHtVmBQ5rt5" balance = "95000000000000000" }, { accountName = "Sun" accountType = "AssetIssue" address = "TWsm8HtU2A5eEzoT8ev8yaoFjHsXLLrckb" balance = "5000000000000000" }, { accountName = "Blackhole" accountType = "AssetIssue" address = "TSJD5rdu6wZXP7F2m3a3tn8Co3JcMjtBip" balance = "-9223372036854775808" }, { accountName = "TestA" accountType = "AssetIssue" address = "TVdyt1s88BdiCjKt6K2YuoSmpWScZYK1QF" balance = "1000000000000000" }, { accountName = "TestB" accountType = "AssetIssue" address = "TCNVmGtkfknHpKSZXepZDXRowHF7kosxcv" balance = "1000000000000000" }, { accountName = "TestC" accountType = "AssetIssue" address = "TAbzgkG8p3yF5aywKVgq9AaAu6hvF2JrVC" balance = "1000000000000000" }, { accountName = "TestD" accountType = "AssetIssue" address = "TMmmvwvkBPBv3Gkw9cGKbZ8PLznYkTu3ep" balance = "1000000000000000" }, { accountName = "TestE" accountType = "AssetIssue" address = "TBJHZu4Sm86aWHtt6VF6KQSzot8vKTuTKx" balance = "1000000000000000" } ]

witnesses = [ { address: TUca2dayrKr1ELWLaY7bLkVxHtVmBQ5rt5, url = "http://tronstudio.com", voteCount = 10000 } ]

timestamp = "0" #2017-8-26 12:00:00

parentHash = "957dc2d350daecc7bb6a38f3938ebde0a0c1cedafe15f0edae4256a2907449f6" }

localwitness = [

]

block = { needSyncCheck = false # first node : false, other : true maintenanceTimeInterval = 21600000 // 1 day: 86400000(ms), 6 hours: 21600000(ms) }

vm = { supportConstant = true minTimeRatio = 0.0 maxTimeRatio = 5.0 }

committee = { allowCreationOfContracts = 1 //mainnet:0 (reset by committee),test:1 allowSameTokenName = 1 allowTvmTransferTrc10 = 1 }

event.subscribe = { native = { useNativeQueue = true // if true, use native message queue, else use event plugin. bindport = 5555 // bind port sendqueuelength = 1000 //max length of send queue }

path = "" // absolute path of plugin server = "" // target server address to receive event triggers dbconfig = "" // dbname|username|password contractParse = true, topics = [ { triggerName = "block" // block trigger, the value can't be modified enable = false topic = "block" // plugin topic, the value could be modified }, { triggerName = "transaction" enable = false topic = "transaction" }, { triggerName = "contractevent" enable = false topic = "contractevent" }, { triggerName = "contractlog" enable = false topic = "contractlog" }, { triggerName = "solidity" // solidity block event trigger, the value can't be modified enable = true // the default value is true topic = "solidity" } ]

filter = { fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range contractAddress = [ "" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address. ]

contractTopic = [
  "" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
]

} }


constant_result: [ '' ] <--- Please tell me how to solve it

CarlChaoCarl commented 1 week ago

Please check your operation of creating a TRC20 token with TronBox. Was it created on the private chain? If not, then it's correct that it cannot be found.

mbc3377 commented 1 week ago

Please check your operation of creating a TRC20 token with TronBox. Was it created on the private chain? If not, then it's correct that it cannot be found.

TRC20 source -> https://github.com/TRON-Developer-Hub/TRC20-Contract-Template

The source is the same, but by changing the tronbox.js file,

1) private chain - tronbox.js module.exports = { networks: { development: { from: 'TUca2dayrKr1ELWLaY7bLkVxHtVmBQ5rt5', privateKey: '**** ', userFeePercentage: 30, feeLimit: 1e9, originEnergyLimit: 1e7, fullHost: "http://127.0.0.1:16667", network_id: "*" }, production: {} } };

deploy -->

{ result: { result: true }, constant_result: [ '' ], transaction: { ret: [ {} ], visible: false, txID: '46b54aa2f680bee057ac6677c9cce7cd7b33cce53ff8bc7d4ceb1a497a5b6e73', raw_data: { contract: [Array], ref_block_bytes: '8a99', ref_block_hash: '22df0a9765b0b909', expiration: 1719497505000, timestamp: 1719497445524 }, raw_data_hex: '0a028a99220822df0a9765b0b90940e8f1a6d085325a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a1541cc83350e01a0a8fba6a548e8d08c97646715de921215415a5264c1cc0dc5ca030d14e4470c23c8ee58af89222470a08231000000000000000000000000cc83350e01a0a8fba6a548e8d08c97646715de927094a1a3d08532' } }

2) api.nileex.io - tronbox.js module.exports = { networks: { development: { from: 'TMiBute5dNRwisGdpERW9ttA1fY5RxCWHJ', privateKey: '***', userFeePercentage: 30, feeLimit: 1e9, originEnergyLimit: 1e7, fullHost: 'https://api.nileex.io', network_id: '3' }, production: {} } };

{ result: { result: true }, energy_used: 509, constant_result: [ '0000000000000000000000000000000000000000204fce5e3e25025e44be8800' ], transaction: { ret: [ {} ], visible: false, txID: '502dd072f4d944ff1d5c18e5d31c084991d281bebd6116c668e42d8a870a956c', raw_data: { contract: [Array], ref_block_bytes: '6ed9', ref_block_hash: '0864bb4dcc5d756d', expiration: 1719495006000, timestamp: 1719494947976 }, raw_data_hex: '0a026ed922080864bb4dcc5d756d40b0ae8ecf85325a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a154180ca5c6032e9a8538e2359fe96a73808f8196c1612154124e810d950675c1b939bfa65667e675c9a4c616c222470a0823100000000000000000000000080ca5c6032e9a8538e2359fe96a73808f8196c167088e98acf8532' } }

It doesn't work in private chain with the same source file, but it works fine in api.nileex.io.

Why doesn't it work in private chain?

ExOCeo commented 1 week ago

Your seed node ip list should be changed to your witness to make sure the node is synced and as the result of your request.

CarlChaoCarl commented 1 week ago

@mbc3377

Hello, do you have any further questions? If your issue has been resolved, you can close this issue.