Comments (9)
after you add signatures to the transaction do,
tx.buildTransaction()
it will get you the final txHash and the cbor hex to be submitted to the submit-api
from typhonjs.
Ok so I removed the following:
// THIS IS WHERE IT GETS MESSED UP I BELIEVE
let txCbor = Encoder.encode(tx).toString("hex")
const data = {
addressBuffer: Buffer.from(
paymentCred0.hash,
"hex"
),
publicKeyBuffer: Buffer.from(
payAddress.addressHex,
"hex"
),
signature: Buffer.from(txCbor, "hex"),
};
const protectedMap = new Map();
// Set protected headers as per CIP08
// Set Algorthm used by Cardano keys
protectedMap.set(1, -8);
// Set PublicKey
protectedMap.set(4, data.publicKeyBuffer);
// Set Address
protectedMap.set("address", data.addressBuffer);
const coseSign1Builder = new CoseSign1({
protectedMap,
unProtectedMap: new Map(),
payload: Buffer.from(""),
hashPayload: false,
});
const coseSign1 = coseSign1Builder.buildMessage(data.signature);
// console.log(txCbor)
console.log(coseSign1.toString("hex"))
// console.log(payAddress.addressBytes)
and replaced them with:
const txFinal = tx.buildTransaction()
// tx.buildTransaction()
console.log(txFinal)
const headers = {
"Content-Type": "application/cbor"
}
const apiAddress = "https://api.koios.rest/api/v0/submittx"
async function postTx() {
try {
const response = await axios.post(apiAddress, txFinal, { headers });
console.log(response);
// return response.data
} catch (error) {
console.error(error);
}
}
postTx()
finalTx looks like:
{
hash: '9be6847a14d94f544114a53391870d9ee430a2aea3ca4f86a41b5dd345a685ba',
payload: '84a40081825820aa6e3c206a746d54f01c1a5784af38c6ffde22d31df1cb1df23966a82caad6e7000182825839011386a2cb3c846a1f93c4af21e7b417e8695c3c2110b0a45200e04c7729d860f24db593de2cb555f5f6b136d79021ac17640dead5e1dc14591a00124f80825839013b64f00fc61bc8abe86830e3a04b711d5aa322b9e7020240e087857e735b09b8ad8a36226c92a6d4801e3eef6710e3eec708f867ef5786551a0018e673021a000290cd031a000aae60a100818258201508404d219c65f534f0f969c4105406b4735e6ae4daa3694b3c2072b45d94465840860bdd3c9bdeff8605e10a78592d8c88c91dc60b81ac37a0f8e34796afd803191e141cfeecab944cb3811633e1d3b2cf167397729f81a21be1b26fd9b6f2950bf5f6'
}
The response from the koios api is:
'transaction read error RawCborDecodeError [DecoderErrorDeserialiseFailure "Byron Tx" (DeserialiseFailure 0 "expected list len"),DecoderErrorDeserialiseFailure "Shelley Tx" (DeserialiseFailure 0 "expected list len or indef"),DecoderErrorDeserialiseFailure "Shelley Tx" (DeserialiseFailure 0 "expected list len or indef"),DecoderErrorDeserialiseFailure "Shelley Tx" (DeserialiseFailure 0 "expected list len or indef"),DecoderErrorDeserialiseFailure "Shelley Tx" (DeserialiseFailure 0 "expected list len or indef")]'
Assuming txFinal is signed and final I should retrace my steps and look for any mistakes? Everything else seems fine?
Appreciate it
from typhonjs.
you should be submitting only the payload to the API, txFinal.payload
from typhonjs.
you should be submitting only the payload to the API,
txFinal.payload
Still not working but I am getting closer, I changed the following (besides only posting txFinal.payload and adjusting TTL)
const privateKey = rootKey.derive(0).derive(0).toPrivateKey();
to
const privateKey = accountKey;
Since I already derived it fully.
Currently looking at protocolParams since there are 3 values I do not know how you got them because they are not in genesis file:
minFeeA: new BigNumber(44),
minFeeB: new BigNumber(155381),
stakeKeyDeposit: new BigNumber(2000000)
from typhonjs.
You will get the proto params using the cardano-li query
from typhonjs.
You will get the proto params using the cardano-li query
That is what I've been doing correct.
However they differ a little, if we remove the "PlutusV1" category from each, we can see in protocolParams (this package):
{
minFeeA: new BigNumber(44),
minFeeB: new BigNumber(155381),
stakeKeyDeposit: new BigNumber(2000000),
lovelacePerUtxoWord: new BigNumber(34482),
collateralPercent: new BigNumber(150),
priceSteps: new BigNumber(0.0577),
priceMem: new BigNumber(0.0000721),
}
and in the json from cardano-cli:
{
"lovelacePerUTxOWord": 34482,
"executionPrices": {
"prSteps": {
"numerator": 721,
"denominator": 10000000
},
"prMem": {
"numerator": 577,
"denominator": 10000
}
},
"maxTxExUnits": {
"exUnitsMem": 10000000,
"exUnitsSteps": 10000000000
},
"maxBlockExUnits": {
"exUnitsMem": 50000000,
"exUnitsSteps": 40000000000
},
"maxValueSize": 5000,
"collateralPercentage": 150,
"maxCollateralInputs": 3,
}
So I do not know how to extract minFeeA / minFeeB / stakeKeyDeposit from the cardano-cli json.
from typhonjs.
Is CIP08 required to sign txFinal?
from typhonjs.
Nope, cip08 is for a different use case
from typhonjs.
So I had to just put the cbor inside:
{
"type": "Tx AlonzoEra",
"description": "",
"cborHex": "84a40081825820aa6e3c206a746d54f01c1a5784af38c6ffde22d31df1cb1df23966a82caad6e7000182825839011386a2cb3c846a1f93c4af21e7b417e8695c3c2110b0a45200e04c7729d860f24db593de2cb555f5f6b136d79021ac17640dead5e1dc14591a00124f80825839013b64f00fc61bc8abe86830e3a04b711d5aa322b9e7020240e087857e735b09b8ad8a36226c92a6d4801e3eef6710e3eec708f867ef5786551a0018e673021a000290cd031a040a6ac7a10081825820fefff5e86c41d9e08ee8d133fad8b3582bf216f62339adf1f29345fab4417a6e58400ff81c3fb6ef3d654f0f2b063906db2efac2c9b1eddc8d37bfe4c046024b65826dcad268b00178e7c4f200dccaaef9098f1e4745d919fac08ab92742594ef70af5f6"
}
Also the values from the json were there I was just looking at another genesis file from another wallet. I was just looking at all the wrong places. Thank you for the support I am now on the right track.
from typhonjs.
Related Issues (17)
- lovelacePerUtxoWord should be coinsPerUtxoWord HOT 1
- createPlutusDataCbor doesn't accept certain acceptable structures to cardano-cli HOT 2
- getAddressFromHex method parameter problem HOT 7
- [Help] Issues with transforming signedTX to be accepted by submit-api endpoint HOT 3
- How to serialise balance in typhonjs HOT 1
- Issue when minting with time-locked policyId HOT 2
- Need to update calculateMinUtxoAmount() for Babbage era HOT 7
- Update StricaHQ/cbors HOT 1
- What about GitHub actions? HOT 1
- Accept hash as a Buffer in Credential HOT 2
- Limit UTXOs selection by overall maxTxSize HOT 2
- Accept Number in protocol params and UTXOs HOT 1
- Feature: decode raw transaction HOT 1
- a error message about `stream`. HOT 1
- window.typhoncip30.getBalance takes long time. HOT 2
- [Feature] Migrate to native BigInt HOT 3
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 typhonjs.