I am trying to build a multisig transaction application by following the Nami Multisig documentation here.
As you probably know that you will need a policyID and policy script to perform a transaction. And nami-js already have a function that generates new policyScript and policyID in here.
The problem is I don’t want to generate a new policyID, I would like to use the policy ID I have created through CLI. Here is my policy.script file
{
"type": "all",
"scripts":
[
{
"type": "before",
"slot": 16584779
},
{
"type": "sig",
"keyHash": "7242f6c68967db0b1aba097ef5a86c558d024902365b4a883b42154f"
}
]
}
And the generated ID is
899418e2dd89a092f00db1484c693ec80040c5479b8058183ae7dea2
As I said, I would like to use my existing policy ID, so I modified to code to generate a policy script based on my keyHash and slot.
async createLockingPolicyScript(address, networkId, expirationTime) {
const ttl = 16584779;
const paymentKeyHash = this.S.Ed25519KeyHash.from_bytes(Buffer.from('7242f6c68967db0b1aba097ef5a86c558d024902365b4a883b42154f', 'hex'))
const nativeScripts = this.S.NativeScripts.new();
const script = this.S.ScriptPubkey.new(paymentKeyHash);
const nativeScript = this.S.NativeScript.new_script_pubkey(script);
const lockScript = this.S.NativeScript.new_timelock_expiry(
this.S.TimelockExpiry.new(ttl)
);
nativeScripts.add(lockScript);
nativeScripts.add(nativeScript);
const finalScript = this.S.NativeScript.new_script_all(
this.S.ScriptAll.new(nativeScripts)
);
const policyId = Buffer.from(
this.S.ScriptHash.from_bytes(
finalScript.hash().to_bytes()
).to_bytes(),
"hex"
).toString("hex");
return {
id: policyId,
script: Buffer.from(finalScript.to_bytes()).toString("hex"),
paymentKeyHash: Buffer.from(paymentKeyHash.to_bytes(), "hex").toString("hex"),
ttl
};
}
It worked and it generated output as follows:-
policyId: 899418e2dd89a092f00db1484c693ec80040c5479b8058183ae7dea2
policyScript: 82018282051a00fd104b8200581c7242f6c68967db0b1aba097ef5a86c558d024902365b4a883b42154f
paymentKeyHash: 7242f6c68967db0b1aba097ef5a86c558d024902365b4a883b42154f
ttl: 16584779
But the problem is, when I’m trying to perform a transaction, I am receiving the following error:-
transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (WrappedShelleyEraFailure (ScriptWitnessNotValidatingUTXOW (fromList [ScriptHash \\"899418e2dd89a092f00db1484c693ec80040c5479b8058183ae7dea2\\"]))))])