【问题标题】:Kadena Pact Create Account FailsKadena Pact 创建帐户失败
【发布时间】:2022-12-03 06:41:48
【问题描述】:

嗨 Kadena Pact 开发者,

我正在关注https://docs.kadena.io/build/frontend/pact-lang-api-cookbook#create-account 创建硬币账户。

getBalance(`sender00`)回报

{
  "gas": 20,
  "result": {
    "status": "success",
    "data": 99998999.9999446
  },
  "reqKey": "AnmQHR9ciGruzwaV2LksjFANS8Mbr5UBuj26d2w4TLE",
  "logs": "wsATyGqckuIvlm89hhd2j4t6RMkCrcwJe_oeCYr7Th8",
  "metaData": {
    "publicMeta": {
      "creationTime": 1670018678,
      "ttl": 28000,
      "gasLimit": 600,
      "chainId": "0",
      "gasPrice": 1e-7,
      "sender": "368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca"
    },
    "blockTime": 1670018669855184,
    "prevBlockHash": "g5bNGUcMPQYC4klTi-D0QhsMBIT9oggVa_-Ea8hyQq4",
    "blockHeight": 1964
  },
  "continuation": null,
  "txId": null
}

我想使用 sender00 密钥对创建另一个帐户,但是失败并显示错误消息

Validation failed for hash "iu9bake1-nzhfQuYoRCM_LggDBenBLDWjGf6o7d00kY": Attempt to buy gas failed with: : Failure: Tx Failed: read: row not found: 368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca

这是整个脚本和.env文件

SENDER00_PUBLIC=368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca
SENDER00_SECRET=251a920c403ae8c8f65f59142316af3c82b631fba46ddea92ee8c95035bd2898

脚本文件

import * as dotenv from 'dotenv'
dotenv.config()
import Pact from 'pact-lang-api';

const GAS_PRICE = 0.0000001;
const GAS_LIMIT = 400;
const TTL = 28000;
const NETWORK_ID = 'development'//'testnet04';
const CHAIN_ID = '0';
const API_HOST = `http://localhost:8080/chainweb/0.0/${NETWORK_ID}/chain/${CHAIN_ID}/pact`;

const creationTime = () => Math.round((new Date).getTime() / 1000) - 15;

async function getBalance(account) {
  const cmd = {
    networkId: NETWORK_ID,
    keyPairs: KEY_PAIR,
    pactCode: `(coin.get-balance "${account}")`,
    envData: {},
    meta: {
      creationTime: creationTime(),
      ttl: 28000,
      gasLimit: 600,
      chainId: CHAIN_ID,
      gasPrice: 0.0000001,
      sender: KEY_PAIR.publicKey
    }
  };

  const result = await Pact.fetch.local(cmd, API_HOST);
  console.log(JSON.stringify(result, null, 2));
}


const KEY_PAIR = {
  'publicKey': `${process.env.SENDER00_PUBLIC}`,
  'secretKey': `${process.env.SENDER00_SECRET}`
}


async function createAccount(newAccount) {
  const cmd = {
    networkId: NETWORK_ID,
    keyPairs: KEY_PAIR,
    pactCode: `(coin.create-account "${newAccount}" (read-keyset "account-keyset"))`,
    envData: {
      "account-keyset": {
        keys: [
          // Drop the k:
          newAccount.substr(2)
        ],
        pred: "keys-all"
      },
    },
    meta: {
      creationTime: creationTime(),
      ttl: 28000,
      gasLimit: 600,
      chainId: CHAIN_ID,
      gasPrice: 0.0000001,
      sender: KEY_PAIR.publicKey
    }
  };

  const response = await Pact.fetch.send(cmd, API_HOST);
  if (!response.requestKeys)
  {
    return console.error(response)
  }
  console.log(`Request key: ${response.requestKeys[0]}`);
  console.log("Transaction pending...");
  const txResult = await Pact.fetch.listen(
    { listen: response.requestKeys[0] },
    API_HOST
  );
  console.log("Transaction mined!");
  console.log(txResult);
}


await getBalance(`sender00`) // OK
await createAccount(`testaccount`)

【问题讨论】:

    标签: pact-lang kadena


    【解决方案1】:

    我将 cmd.meta.sender 中的 sender 更改为 sender00 并且有效。 我认为公钥和帐户名是不同的东西。

    【讨论】:

      猜你喜欢
      • 2022-11-19
      • 2017-03-20
      • 2016-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-31
      • 1970-01-01
      • 2012-01-19
      相关资源
      最近更新 更多