Comments (4)
What are these bytes and where did you get them? When I try to parse them using Tx.fromBuffer() I get different messages.
from avalanchejs.
Examples are OperationTx
s on X-Chain. Bytes come from getTx
API of avalanchego
and they are CB58-encoded.
Here follows the whole stacktrace for Example n.1 and n.2:
Error: Error - NBytes.fromBuffer: Error: Buffer length must be 20 bytes. Only have 6 remaining in buffer.
at Address.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/common/nbytes.js:81:19)
at SECPTransferOutput.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/common/output.js:242:27)
at SECPTransferOutput.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/common/output.js:404:22)
at SECPMintOperation.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/apis/avm/ops.js:308:34)
at TransferableOperation.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/apis/avm/ops.js:202:31)
at OperationTx.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/apis/avm/operationtx.js:91:25)
at UnsignedTx.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/apis/avm/tx.js:75:33)
at Tx.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/apis/avm/tx.js:120:34)
at main (/home/XXX/parsetx/index.js:28:23)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Here follows the whole stacktrace for Example n.3:
Error: Error - SelectCredentialClass: unknown credid 0
at Object.exports.SelectCredentialClass (/home/XXX/parsetx/node_modules/avalanche/dist/apis/avm/credentials.js:35:11)
at Tx.fromBuffer (/home/XXX/parsetx/node_modules/avalanche/dist/apis/avm/tx.js:127:40)
at main (/home/XXX/parsetx/index.js:28:23)
at processTicksAndRejections (internal/process/task_queues.js:93:5
The issue is that SECPMintOperation
has a single TransferOutput
(as reported here https://github.com/ava-labs/avalanchego/blob/master/vms/avm/vm.go#L1053), but here https://github.com/ava-labs/avalanchejs/blob/master/src/apis/avm/ops.ts#L323 a list of TransferOutput
s is parsed.
from avalanchejs.
Great!! Thanks! I'll work on a patch as my next priority after what I'm currently on.
from avalanchejs.
This has been resolved. You can parse the bytes like so
import { BinTools, Buffer } from "../../src"
import {
Tx,
} from "../../src/apis/avm"
const bintools: BinTools = BinTools.getInstance()
const bytes: string = "11111eqtQvbRXgLu2Ggh1sfXyRxKRFwxiSC283i1LX8fS8uyHtcbbWDxASbh9ktwpg45Hnb5DXR8rHHp9opSTuPZZ1yHpPXP2dm6WDJtjJsmjcSCptEscH2dUJB1JEw2hTDWjrWZAjTKZiY2RHrJrEcsySqJA1byCMpxekKByTkpHJd8TjGLqEFsf5qmY8LxmAhUi16zoJhXAbLRHgiwTQ9vTxAdL4SUpmTjjnKWdF5Jh59CNfF61KZGzWy7ATxjGLL9RGzy1rQrxLvnL8KxFx8HyShNYrPdoLsRkwVA6htAfN9DaLen2WyGpjCCfMShzAhfqD1bdKshVNncviLEXisCds2dnjLspeTudhBocqA7fsb5bVPHD15Lrvdk3RZsRBBoiFi1MkFxsRFWRDwej4izcj7UUoXE3vUJkev7hgdPoALUDjfgsyTTHei3nSrFbVYhe7MGWBRi8aqsdEurLf9ttQEirfpLbtiK1owbwm8Cs8VuW6Mzj58tJbsh14dqHAMF7zoPuA2GWBcvxczdJTS17RpYMdNbJtwXqxGw9QD4brHwZr1SewAd1nyZwpVquYvSwNMaMbtYuowVXzXaJ9VBR4EBN3skqZLVpomXCFvzw34Ry2RDGHAKa4nRWsY6vTaQ1ZFhUPYQknj82ru4axs8zZyWSCHx5bsvc2Nj9TmaC9Paubwb4b9YFkrhGfwBQHrUybWxMepuSg5GnKQvV8MXVZUTJgEyWb72"
const bytesBuf: Buffer = bintools.cb58Decode(bytes)
const main = async (): Promise<any> => {
const tx: Tx = new Tx()
tx.fromBuffer(bytesBuf)
console.log(tx)
}
main()
from avalanchejs.
Related Issues (20)
- mnemonic.generateMnemnonic() Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call')
- feature request: Banff Update Support
- getPreferredHRP returns incorrect prefix HOT 1
- Defaults.network[networkID].C.blockchainID returns incorrect Blockchain ID
- AvalancheCore.post request is not working with URL of format https://username:[email protected]
- How to get pending transactions HOT 1
- getAtomicTx method does not return the block height
- Pchain getBalance doesn't work
- Missing @avalabs/avalanchejs on yarn package manager
- X-Chain getting UTXO set example uses wrong variable!
- unable to parse block in js
- how to parse block in js
- getContainerByIndex problem with 3.17.0
- Decoding atomic transaction from byte data returned by `getAtomicTx` rpc call HOT 1
- Security: insecure deps are used, switch to better ones HOT 2
- Cannot use v3.18.1 for addPermissionlessValidator and addPermissionlessDelegator Transactions
- Export C-to-X example does not work HOT 3
- exec delegate.ts issue
- Add support for AddPermissionlessValidator and AddPermissionlessDelegator transactions in v3
- Support for Node18 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avalanchejs.