Comments (5)
Adding my code here:
const nodeUrl =******
const core = new Core(nodeUrl)
let secp256k1Dep = await core.loadSecp256k1Dep();
let pubKey = '0x035a27b3564c6a08337ba07f8120551d5721e9ae888bcd60df705de7509d2bc73d';
let address = CKBUtils.pubkeyToAddress(pubKey, {prefix: 'ckt'});
let pubKeyHash = '0x' + CKBUtils.blake160(pubKey, 'hex');
let codeHash = secp256k1Dep.codeHash;
let lockScript = {
hashType: "type",
codeHash: codeHash,
args: pubKeyHash
}
let lockHash = CKBUtils.scriptToHash(lockScript);
let unspentCells = await core.loadCells({lockHash})
let rawTransaction = await core.generateRawTransaction({
fromAddress: 'ckt1qyqdjvjspzuj0vjg85duwl8s9a8x32u3ddksef5eqc',
toAddress: 'ckt1qyqwkcma99gj3zlh2wwzzd2etawegg90lepssacpmh',
capacity: 7000000000,
fee: 100000,
safeMode: true,
cells: unspentCells,
deps: core.config.secp256k1Dep,
})
rawTransaction.witnesses = rawTransaction.inputs.map(() => '0x')
rawTransaction.witnesses[0] = {
lock: '',
inputType: '',
outputType: ''
}
let privateKey = '0x7faf9bddf383c4ac07b32f7001905975c0b91761e9794590c4e5475583362bdc'
const signedTx = core.signTransaction(privateKey)(rawTransaction);
const realTxHash = await core.rpc.sendTransaction(signedTx);
console.log('The real transaction hash is:', realTxHash)
from ckb-sdk-js.
I've run the example and it works
const Core = require('../lib').default
const bootstrap = async () => {
const nodeUrl = 'http://localhost:8114'
const core = new Core(nodeUrl)
const secp256k1Dep = await core.loadSecp256k1Dep()
const CKBUtils = core.utils
const pubKey = '0x035a27b3564c6a08337ba07f8120551d5721e9ae888bcd60df705de7509d2bc73d'
// const address = CKBUtils.pubkeyToAddress(pubKey, {
// prefix: 'ckt',
// })
const pubKeyHash = `0x${CKBUtils.blake160(pubKey, 'hex')}`
const { codeHash } = secp256k1Dep
const lockScript = {
hashType: 'type',
codeHash,
args: pubKeyHash,
}
const lockHash = CKBUtils.scriptToHash(lockScript)
const unspentCells = await core.loadCells({
lockHash,
})
const rawTransaction = await core.generateRawTransaction({
fromAddress: 'ckt1qyqdjvjspzuj0vjg85duwl8s9a8x32u3ddksef5eqc',
toAddress: 'ckt1qyqwkcma99gj3zlh2wwzzd2etawegg90lepssacpmh',
capacity: 7000000000,
fee: 100000,
safeMode: true,
cells: unspentCells,
deps: core.config.secp256k1Dep,
})
rawTransaction.witnesses = rawTransaction.inputs.map(() => '0x')
rawTransaction.witnesses[0] = {
lock: '',
inputType: '',
outputType: '',
}
const privateKey = '0x7faf9bddf383c4ac07b32f7001905975c0b91761e9794590c4e5475583362bdc'
const signedTx = core.signTransaction(privateKey)(rawTransaction)
const realTxHash = await core.rpc.sendTransaction(signedTx)
console.log('The real transaction hash is:', realTxHash)
}
bootstrap()
Could you please post the versions of ckb-sdk-js
and ckb
, and the signed transaction generated by the sdk here? Thanks.
from ckb-sdk-js.
versions:
ckb-sdk-js:0.23.1
and I will ask ckb version later.
signed transaction:
{"version":"0x0","cellDeps":[{"outPoint":{"txHash":"0xbd864a269201d7052d4eb3f753f49f7c68b8edc386afc8bb6ef3e15a05facca2","index":"0x0"},"depType":"depGroup"}],"headerDeps":[],"inputs":[{"previousOutput":{"txHash":"0x9f15aaa6be33632d0f6f70a711b72d7671ce1920330a0dee5e94e636a515fa48","index":"0x0"},"since":"0x0"}],"outputs":[{"capacity":"0x1a13b8600","lock":{"hashType":"type","codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","args":"0xeb637d2951288bf7539c2135595f5d9420affe43"}},{"capacity":"0x72c9170200","lock":{"codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hashType":"type","args":"0xd9325008b927b2483d1bc77cf02f4e68ab916b6d"}}],"witnesses":["0x9aec5105f107c49f77db285a28edc007c2c9e60dd36a77084565f08c737d11b305fb5b5bf896c72009a40c8914b429fd961b97be80279f4e28b3d0d29abe6500000000000c000bec00"],"outputsData":["0x","0x"]}
from ckb-sdk-js.
versions:
ckb-sdk-js:0.23.1
and I will ask ckb version later.signed transaction: {"version":"0x0","cellDeps":[{"outPoint":{"txHash":"0xbd864a269201d7052d4eb3f753f49f7c68b8edc386afc8bb6ef3e15a05facca2","index":"0x0"},"depType":"depGroup"}],"headerDeps":[],"inputs":[{"previousOutput":{"txHash":"0x9f15aaa6be33632d0f6f70a711b72d7671ce1920330a0dee5e94e636a515fa48","index":"0x0"},"since":"0x0"}],"outputs":[{"capacity":"0x1a13b8600","lock":{"hashType":"type","codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","args":"0xeb637d2951288bf7539c2135595f5d9420affe43"}},{"capacity":"0x72c9170200","lock":{"codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hashType":"type","args":"0xd9325008b927b2483d1bc77cf02f4e68ab916b6d"}}],"witnesses":["0x9aec5105f107c49f77db285a28edc007c2c9e60dd36a77084565f08c737d11b305fb5b5bf896c72009a40c8914b429fd961b97be80279f4e28b3d0d29abe6500000000000c000bec00"],"outputsData":["0x","0x"]}
If the version of CKB
is v0.24.*
, I guess upgrading the SDK to v0.24.0
will fix this error.
The signature has changed in v0.24.
from ckb-sdk-js.
versions:
ckb-sdk-js:0.23.1
and I will ask ckb version later.signed transaction: {"version":"0x0","cellDeps":[{"outPoint":{"txHash":"0xbd864a269201d7052d4eb3f753f49f7c68b8edc386afc8bb6ef3e15a05facca2","index":"0x0"},"depType":"depGroup"}],"headerDeps":[],"inputs":[{"previousOutput":{"txHash":"0x9f15aaa6be33632d0f6f70a711b72d7671ce1920330a0dee5e94e636a515fa48","index":"0x0"},"since":"0x0"}],"outputs":[{"capacity":"0x1a13b8600","lock":{"hashType":"type","codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","args":"0xeb637d2951288bf7539c2135595f5d9420affe43"}},{"capacity":"0x72c9170200","lock":{"codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8","hashType":"type","args":"0xd9325008b927b2483d1bc77cf02f4e68ab916b6d"}}],"witnesses":["0x9aec5105f107c49f77db285a28edc007c2c9e60dd36a77084565f08c737d11b305fb5b5bf896c72009a40c8914b429fd961b97be80279f4e28b3d0d29abe6500000000000c000bec00"],"outputsData":["0x","0x"]}
If the version of
CKB
isv0.24.*
, I guess upgrading the SDK tov0.24.0
will fix this error.The signature has changed in v0.24.
I update the version and it works! Thanks alot
from ckb-sdk-js.
Related Issues (20)
- Deploy the Anyone-can-pay contract
- 相同的tx数据,通过不同的工具进行签名,witnesses不一样 HOT 9
- Update build badges on next release
- Replace axios HOT 1
- Duplicate transaction error HOT 19
- Upgrade dot-prop
- Blake160 in C HOT 1
- iOS 11 下会因为 wasm 导致 crash HOT 9
- Enable sign message with specified prefix
- 0.36.0 doesn't compile with typescript 4.0.3 HOT 3
- Set `cells` in `signTransaction` optional
- merkle_tree
- CKB2021 compatibility HOT 1
- Add a method to deserialize witness
- Code hash error when attempting to generate full address from private key. HOT 3
- I can transfer money on the testnet, but I get an error when I switch to the mainnet HOT 5
- Use `systemScripts` module instead of `setSecp256k1Dep` method
- Limitation of address type should be reinforced
- Dao related problems, please help me to have a look HOT 3
- createBatchRequest need to handle the case when params is an empty array HOT 1
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 ckb-sdk-js.