'tezos multisig packdata taquito
import { BatchOperation, TezosToolkit, MANAGER_LAMBDA } from '@taquito/taquito';
import { InMemorySigner } from '@taquito/signer';
import { KeyToken } from '@taquito/michelson-encoder/dist/types/tokens/key';
import { b58cencode, char2Bytes, Prefix, prefix } from '@taquito/utils';
import {SchemaOfParams1} from './schema1';
import {SchemaOfParams2} from './schema2';
const acc = require('./Account.json');
const RPC_URL = 'https://rpc.hangzhounet.teztnets.xyz';
const CONTRACT_MSIG = 'KT1NKRT1sdGZjpsN8qNNEX3fqNnSi6ReujSK';
const CONTRACT='KT19xGcNnDwB8uYy18k93FjFv9KNDEivbq87';
const RECEIVER = 'tz1LiBrF9gibgH5Lf6a7gDjoUfSEg6nxPKsz';
const AMOUNT = '1';
const ID='1';
const signer =new InMemorySigner('edskRrZRXU2vgyFgMt94BKY2Fv1bQCFLrgwo2DwseLoYDvpjZeNohKC1afZtRT55NhhLfAj46PGVL1jAy8WEJZ1m4n3F2Kkc7i');
export class token_transfer {
private tezos: TezosToolkit;
rpcUrl: string;
constructor(rpcUrl: string) {
this.tezos = new TezosToolkit(rpcUrl);
this.rpcUrl = rpcUrl;
this.tezos.setSignerProvider(signer);
}
public async transfer(contractmsig: string,contract1:string,receiver:string, amount:string, id:string) {
const contract = await this.tezos.contract.at(contractmsig);
console.log("Packing started...");
const pair = ({ data, type }: any, value: any) => {
return {
data: {
prim: 'Pair',
args: [{ "string": value }, data]
},
type: {
prim: 'pair',
args: [{ prim: "address" }, type]
}
}
}
const { packed } = await this.tezos.rpc.packData(pair({
data: {
prim:'Pair',
args:[
{'int':'1'},
{
prim:'Left',
args:[{
prim:'Left',
args:[{
prim:'Left',
args:[{
prim:'Left',
args:[{
prim: 'Pair',
args:[
{'string':'tz1Qw2LiqMNwJXKKzimAVMWj5W467Hrd6dP7'},
{'int':'1000'},
]
}]
}]
}]
}]
}
]
} as any,
type: SchemaOfParams2
},contractmsig));
const signature = signer.sign(packed, new Uint8Array());
console.log('Transaction started...');
try{
const op = await contract.methods.main_parameter(
// Counter
'1',
'1',
'tz1Qw2LiqMNwJXKKzimAVMWj5W467Hrd6dP7',
'1000',
[(await signature).prefixSig]
).send()
console.log('Awaiting confirmation...');
await op.confirmation();
console.log(op.hash);
}catch(er){console.log(er)}
} }
new token_transfer(RPC_URL).transfer(CONTRACT_MSIG,CONTRACT,RECEIVER,AMOUNT,ID);
SchemaOfParams2:
{
"prim": "pair",
"args": [
{ "prim": "nat", "annots": [ ":counter" ] },
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{
"prim": "or",
"args": [
{ "prim": "pair", "args": [ { "prim": "address", "annots": [ ":to" ] }, { "prim": "mutez", "annots": [ ":value" ] } ] },
{ "prim": "option", "args": [ { "prim": "key_hash" } ], "annots": [ ":delegation" ] }
],
"annots": [ ":direct_action" ]
},
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [
{ "prim": "address" },
{
"prim": "or",
"args": [
{
"prim": "pair",
"args": [ { "prim": "address" }, { "prim": "pair", "args": [ { "prim": "address" }, { "prim": "nat" } ] } ],
"annots": [ ":transferFA1.2" ]
},
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{ "prim": "address", "annots": [ ":from_" ] },
{
"prim": "list",
"args": [
{
"prim": "pair",
"args": [
{ "prim": "address", "annots": [ ":to_" ] },
{ "prim": "pair", "args": [ { "prim": "nat", "annots": [ ":token_id" ] }, { "prim": "nat", "annots": [ ":amount" ] } ] }
]
}
],
"annots": [ ":txs" ]
}
]
}
],
"annots": [ ":transferFA2" ]
}
]
}
],
"annots": [ ":transferFA" ]
},
{
"prim": "pair",
"args": [
{ "prim": "address", "annots": [ ":vesting" ] },
{
"prim": "or",
"args": [
{ "prim": "option", "args": [ { "prim": "key_hash" } ], "annots": [ ":setDelegate" ] },
{ "prim": "nat", "annots": [ ":vest" ] }
]
}
]
}
]
}
],
"annots": [ ":action" ]
},
{ "prim": "lambda", "args": [ { "prim": "unit" }, { "prim": "list", "args": [ { "prim": "operation" } ] } ] }
],
"annots": [ ":actions" ]
},
{ "prim": "pair", "args": [ { "prim": "nat", "annots": [ ":threshold" ] }, { "prim": "list", "args": [ { "prim": "key" } ], "annots": [ ":keys" ] } ] }
]
}
]
};
Error: TezosOperationError: (temporary) proto.011-PtHangz2.michelson_v1.script_rejected When passing parameters to the contract method, it turns out that the parameters that were signed do not match those that were passed to the smart contract. Can someone tell me what I'm doing wrong when packing data and signing it. Please help me :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|