cosmostation / cosmosjs Goto Github PK
View Code? Open in Web Editor NEW:star: CosmosJS - Cosmos JavaScript Library
License: MIT License
:star: CosmosJS - Cosmos JavaScript Library
License: MIT License
cosmos.broadcast(signedTx)
Allow the ability to generate an address with a prefix other than cosmos
.
https://github.com/cosmostation/cosmosjs/blob/master/src/index.js#L65
Of course its ok to default to cosmos
, but allow a parameter to the function, or define it in the instance (like chain-id
).
Hi,
We get an internal error while broadcasting a tx.
Here is our signedTx :
signedTx = {
"tx": {
"msg": stdSignMsg.msg,
"fee": stdSignMsg.fee,
"signatures": [
{
"signature": signatureBase64,
"pub_key": getPubKeyBase64(ecpairPriv)
}
],
"memo": stdSignMsg.memo
},
"mode": "block"
}
The response while broadcasting is:
{
height: '0',
txhash: '6EC99CB505644B8B515B5D130A693FD84F8FCF122BE720F114D93E91D773CABE',
codespace: 'undefined',
code: 111222,
raw_log: 'internal error',
gas_used: '6408'
}
returning checkTx false
Can we get same pub_key from the blockchain and CosmosJS for a signedTx? Right now, we are getting 2 different keys listed as below:
from CosmosJS {"pub_key":"A3LntVjxVBwPyMV1hSi3iFdlAj1mKRtsicozGzqkP5g8"}
from the blockchain {"pub_key":"61rphyEDcue1WPFUHA/IxXWFKLeIV2UCPWYpG2yJyjMbOqQ/mDw="}
I am using your lib in one of my projects and randomly get
'unauthorized: signature verification failed; verify correct account sequence and chain-id
I get the sequence by
cosmos.getAccounts(address).then(data => {
const stdSignMsg = cosmos.newStdMsg({
msgs: [{
type: "veroblockchain/CreateOrder",
value: {
ID: String(mysql_id),
creator: String(address),
company_id: String(company_id),
user_id:String( user_id),
data: String(jsonData)
}
}
],
chain_id: chainId,
fee: { amount: [{ amount: String(11), denom: "token" }], gas: String(200000) },
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
});
What can be the reason? Too fast sending the requests for the same account?
i want to modify the commision rate for a validator , and how can i do ?
Hello 👋
I am trying to create a send transaction on the irishub with cosmosjs.
On the example it shows how to create a transaction
https://github.com/cosmostation/cosmosjs/blob/master/example/irishub.js
let stdSignMsg = iris.newStdMsg({
msgs: [
{
type: "irishub/bank/Send",
value: {
inputs: [
{
address: address,
coins: [
{
denom: "iris-atto",
amount: String(1000000000000000000) // 18 decimal places
}
]
}
],
outputs: [
{
address: "iaa12g4vfyq65yf5cds4v5pr3jmdd4v6s40fkaaxtf",
coins: [
{
denom: "iris-atto",
amount: String(1000000000000000000)
}
]
}
]
}
}
],
chain_id: chainId,
fee: { amount: [ { amount: String(400000000000000000), denom: "iris-atto" } ], gas: String(50000) },
// ☝️ Fee is outside of msgs
memo: "",
account_number: String(data.result.value.account_number),
sequence: String(data.result.value.sequence)
});
In the source code index.js
the fee
is referenced as part of the msgs
array first object
Line 150 in 14114dd
Therefore trying to use the example throws
TypeError: Cannot read property 'amount' of undefined
at Cosmos.newStdMsg (node_modules/@cosmostation/cosmosjs/src/index.js:150:49)
One of the approaches seem to be off, could you adapt the example or the code to the correct case? Or am I doing something wrong? Thank you
Does support signing transactions by private keys in hex?
I've a testnet address cosmos199uttp2xjt90zl5t2unu289ghmt5yt536u2vkz
can you please tell me what will be lcdUrl and chain-id?
Can I generate or derive addresses from a public key (HD wallet) using this library?
Thanks
Add the ability to add multisign a transaction (ie gaiacli tx multisign
). Thanks!
https://hub.cosmos.network/docs/gaiacli.html#multisig-transactions
Hello, this is deprecated within the README
Cosmostation offers LCD url(https://lcd-cosmos-free.cosmostation.io).
This rest server URL may be disabled at any time. In order to maintain stable blockchain service, it is recommended to prepare your rest server.
Setting up the rest server: (https://hub.cosmos.network/master/resources/service-providers.html#setting-up-the-rest-server)
This package is still using the crypto package from npm, which has been replaced by a builtin module and is deprecated.
Hello, guys! Could you, please, explain what the «LCD url» means in the following sentence:
Cosmostation offers LCD url(https://lcd-cosmos-free.cosmostation.io)
and for what purpose does it serve? Do I need to use this URL? Looks like some kind of URL for testing.
Thanks in advance for your reply!
let stdSignMsg = cosmos.newStdMsg({
msgs: [
{
type: 'cosmos-sdk/MsgSend',
value: {
amount: [
{
amount: '10',
denom: 'fmt',
},
],
from_address: ffHubAddress,
to_address: ffHubAddress,
},
},
],
chain_id: chainId,
fee: {
amount: [{
amount: '10',
denom: 'fmt',
}],
gas: '200',
},
memo: '',
account_number: {"${decoded.value.account_number}"}
,
sequence: {"${decoded.value.sequence}"}
,
});
Response:
code: 18
codespace: "sdk"
gas_used: "6408"
height: "0"
raw_log: "must contain at least one message: invalid request"
txhash: "127F087017E3D4ED59D06F536B0168224E910AB20AC07E966B9D3FB43023FB4F"
for e.g I have tx
{"tx":"dCgoFqkKQqijYZoKFCl4tYVGksrxfotXJ8UcqL7XQi6REhRXZEl+uFUvJYKj/5RMcBx+RvPu4hoQCgV1bW91bhIHMjAwMDAwMBIRCgsKBXVtb3VuEgI1MBDAmgwiF1NlbnQgdmlhIENvc21vcyBWb3lhZ2Vy"}
how to sign it or is there any method to decode it and then use parameters in sign.
Hello!
Is it possible to use the SimulateRequest endpoint?
I saw some functions in proto.js but I don't know how to use them
https://docs.cosmos.network/v0.42/core/proto-docs.html#cosmos.tx.v1beta1.SimulateRequest
Thanks 👍
0x8be66f57eda245390cd783e25921caa2cca4e0a5
Is there any testnet? Because mintscan has only one option for cosmoshub-2 which does not differentiate mainnet and testnet.
hi @Booyoun-Kim , you should consider "stargate-final" chain-id whereas it should actually use the same endpoint("/cosmos/auth/v1beta1/accounts/") in the first condition.
https://github.com/cosmostation/cosmosjs/blob/master/src/index.js#L83
I noticed that I ran into a signing verification error when my msg contains an object (like sdk.Coins
, which is an array of objects). Because JSON'ifying an object is non-deterministic, the bytes array isn't deterministic when signing a message.
The binance chain JS code sorts the object as seen here. https://github.com/binance-chain/javascript-sdk/blob/75d955eecb6357940f4b3085821a1edbe22513b5/src/encoder/index.js#L72
Maybe this code base should do something similar.
Is there any way,in js, to decode transactions from mempool (base64)? by get request .../unconfirmed_txs?limit=10000.
txs: [ 0AEoKBapCjCMTXENChS7INS+K/6dQM0sSyiD8DeTauS5VxIUuyDUviv+nUDNLEsog/A3k2rkuVcKGs0ydLMKFLsg1L4r/p1AzSxLKIPwN5Nq5LlXEhAKCgoFdWF0b20SATEQwJoMGmoKJuta6YchAsz2BVSsf/5JQzFzxwvlmvKkl58M6ezWciRoF3XKo3pcEkAuhLiloqCWyw5bcLgzdWthQ6pt5GmbRKjTw4bWdGMTfSQ1rmv7Xx+PH8HS7O8K/TeLeAI6of2F9BUYfaSfeUe6 " ]
Hello and thank you for your lib!
I have encountered a problem since the update to 0.10, there is a problem with the bip39 class, the call made by the Cosmos class to bip39 returns this error:
When I look in the source of src/index.js
, line 38, I do a console.log(bip39)
, like:
I have this result:
I notice right away that the class starts with "Default", just add default
to each call of bip39, bip32 and bech32
Like this:
I forked the project, I made the changes and everything works (atmoner@ead38c0)!
Do you want me to do a pull request?
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.