Closed YaleZheng closed 6 years ago
after explore the closed issue, i found an solution,
import * as ecc from "eosjs-ecc";
import * as eosjs from "eosjs";
async function main() {
const sk = '5Jp4KE9xfjjUT33xdziisRh95UDz3GH6m7bXByUqKRendX6ho8V'
const pk = await ecc.privateToPublic(sk)
const accountName = 'yaleconab'
const client = eosjs.Testnet({
httpEndpoint: 'http://ayeaye.cypherglass.com:8888',
keyProvider: [sk],
broadcast: false,
sign: true,
debug: false,
expireInSeconds: 60,
chainID: 'a628a5a6123d6ed60242560f23354c557f4a02826e223bb38aad79ddeb9afbca',
})
const tx = await client.transaction(tr => {
tr.delegatebw({
from: 'yaleconab',
receiver: 'yaleconab',
stake_net_quantity: '10.0 EOS',
stake_cpu_quantity: '10.0 EOS',
transfer: 0,
})
})
}
main().catch(console.error)
I think eosjs shoud detect the correct chain_id by itself. maybe @jcalfee could add this feature next version
The user needs to accept the chain ID for security reasons.. The chainId is the hash of the genesis state which includes all initial accounts and balances. A man in the middle attack would still be complicated by TaPOS, however, a known valid chainID is still done to help ensure the transactions belong to the intended chain.
https://github.com/EOSIO/eos/search?q=compute_chain_id&unscoped_q=compute_chain_id
I'm running into the same issue but I'm still not able to get it working by following the instructions above.
@YaleZheng After you push a transaction are you able to verify it worked besides it not throwing any errors? When I set broadcast to false it appears to work but eosjs never actually calls push_transaction. When I set broadcast to true I get these errors.
file:"authorization_manager.cpp"
line_number:405
message: "transaction declares authority '{"actor":"randyt","permission":"active"}', but does not have signatures for it under a provided delay of 0 ms"
method:"check_authorization"
http://ayeaye.cypherglass.com:8888/v1/chain/push_transaction {"compression":"none","transaction":{"expiration":"2018-05-29T17:13:36","ref_block_num":9427,"ref_block_prefix":2840150054,"net_usage_words":0,"max_cpu_usage_ms":0,"delay_sec":0,"context_free_actions":[],"actions":[{"account":"eosio","name":"newaccount","authorization":[{"actor":"randyt","permission":"active"}],"data":"00000000649fa6b900000000009fcc3d010000000100032f7829db81aef9dcd5768b26da14d8646998b9396634427c2fb8d5bfecd55c350100000001000000010002eed0aca9c52e0fb048cf55e26bd86ece19916e009244b40ddc6961efda6d1acd01000000"},{"account":"eosio","name":"buyrambytes","authorization":[{"actor":"randyt","permission":"active"}],"data":"00000000649fa6b900000000009fcc3d00200000"},{"account":"eosio","name":"delegatebw","authorization":[{"actor":"randyt","permission":"active"}],"data":"00000000649fa6b900000000009fcc3d102700000000000004454f5300000000102700000000000004454f530000000000"}],"transaction_extensions":[]},"signatures":["SIG_K1_KePtk6hWafWyoZKqRtjDxswMMxSwpw6yByedQkJjyiA6gZowEjKjb7Cfe1eXUGnStF29PM19ZgcZrEaaDzTkdSMk6EPptx"]}
I'm trying to create an account but it just hangs saying "Processing..."
@randytorres look like that u did not generate the correct signature
can u list the environment you depended,and paste you relaitve code here? may be i can give more suggestion?
i have try to delegatebw with boardcast and it work fine too.
import * as eosjs from "eosjs";
import * as ecc from "eosjs-ecc";
async function main() {
const sk = '5Jp4KE9xfjjUT33xdziisRh95UDz3GH6m7bXByUqKRendX6ho8V'
const pk = await ecc.privateToPublic(sk)
const accountName = 'yaleconab'
const client = eosjs.Testnet({
httpEndpoint: 'http://ayeaye.cypherglass.com:8888',
keyProvider: [sk],
sign: true,
debug: false,
expireInSeconds: 60,
chainId: 'a628a5a6123d6ed60242560f23354c557f4a02826e223bb38aad79ddeb9afbca',
})
const tx_signed = await client.transaction(tr => {
tr.delegatebw({
from: 'yaleconab',
receiver: 'yaleconab',
stake_net_quantity: '10.0 EOS',
stake_cpu_quantity: '10.0 EOS',
transfer: 0,
})
}, { broadcast: true })
console.log(JSON.stringify(tx_signed, null, 4))
}
main()
@jcalfee ,I have try to create account again.
Everything work fine.
May be there r some network issues at that time.
After filled your info, and click the create button,u should able to see something like below
thanks @YaleZheng and @jcalfee I was able to figure it out and it wasnt related to eosjs.
I apologize @YaleZheng, I closed too soon .. I'll wait for you to confirm.
it's ok
i just see many people create issue like this so i keep it open. i close it now.
I have a similar issue here https://github.com/EOSIO/eosjs/issues/248
Environment
lib_version: eosjs@13.0.0 testnet_site: http://dev.cryptolions.io/
Brief
it seem fail to perform transaction with eosjs@13.0.0 anytime i perform transaction,eosjs will throw error complain "provided keys, permissions, and delays do not satisfy declared authorizations" but i can do the same transaction with cleos without any error
Code
Cleos
Error