我的 bin 文件大小只有 18kb。我还得到了使用 IPFS 的解决方案,但不知道如何使用它。如果有任何使用 IPFS 的参考,请分享给我。:
错误:PrecheckStatusError:事务 0.0.34898094@1653658245.135892060 预检查失败,状态为 TRANSACTION_OVERSIZE
这是我的代码:
const {
AccountId,
PrivateKey,
Client,
FileCreateTransaction,
ContractCreateTransaction,
ContractFunctionParameters,
ContractExecuteTransaction,
ContractCallQuery,
Hbar
} = require("@hashgraph/sdk");
const fs = require("fs");
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_PVKEY);
const client = Client.forTestnet().setOperator(operatorId, operatorKey);
async function main() {
// Import the compiled contract bytecode
const contractBytecode = fs.readFileSync("first_contract_sol_ABC_TOKEN.bin");
// Create a file on Hedera and store the bytecode
const fileCreateTx = new FileCreateTransaction().setContents(contractBytecode).setKeys([operatorKey]).setMaxTransactionFee(new Hbar(1))
.freezeWith(client);
const fileCreateSign = await fileCreateTx.sign(operatorKey); …Run Code Online (Sandbox Code Playgroud) 我想铸造 100 个 NFT。我需要调用“TokenMintTransaction()”100 次吗?有没有办法在一次 API 调用中铸造 100 个 NFT?
这是我正在使用的代码:
let mintTx = new TokenMintTransaction().setTokenId(tokenId).setMetadata([Buffer.from(CID)]).freezeWith(client);
Run Code Online (Sandbox Code Playgroud)
我可以在 .setMetadata() 中传递什么来铸造多个 NFT?
我目前正在使用 Hedera JS SDK 直接使用私钥作为输入来生成单个 ECDSA 密钥对,如下所示:
const privateKey = PrivateKey.fromStringECDSA(process.env.TARGET_HEX_PRIVATE_KEY);
Run Code Online (Sandbox Code Playgroud)
相反,我想做这样的事情,我使用 BIP-39 种子短语和派生路径作为输入:
const mnemonic = Mnemonic.fromString(process.env.TARGET_SEED_PHRASE);
const privateKey = await mnemonic.toEcdsaPrivateKey('', "m/44'/60'/0'/0/0");
Run Code Online (Sandbox Code Playgroud)
然而,根据其 JsDoc 注释,Mnemonic的toEcdsaPrivateKey函数似乎接受一个数字数组作为派生路径的输入@param,复制如下:
/**
* Recover an ECDSA private key from this mnemonic phrase, with an
* optional passphrase.
*
* @param {string} [passphrase]
* @param {number[]} [path]
* @returns {Promise<PrivateKey>}
*/
async toEcdsaPrivateKey(passphrase = "", path) {
return CACHE.privateKeyConstructor(
await this._mnemonic.toEcdsaPrivateKey(passphrase, path)
);
}
Run Code Online (Sandbox Code Playgroud)
在我的用例中,我想使用 MetaMask,不幸的是,它还不支持每个网络配置的自定义派生路径,而是硬编码了以太坊派生路径m/44'/60'/0'/0/0。请注意,前 …
我正在 Hashscan 上查看一笔交易
它的交易哈希是:
0x89eb7e219df6f8b3b3406c8a3698d5b484a4945059af643861c878e41ffc161b2589cc82ff40b4392ceb53856c5252c1
...这不适用于eth_getTransactionByHashRPC:
TXHASH=0x89eb7e219df6f8b3b3406c8a3698d5b484a4945059af643861c878e41ffc161b2589cc82ff40b4392ceb53856c5252c1
curl -s -X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"2","method":"eth_getTransactionByHash","params":["'"${TXHASH}"'"]}' \
http://localhost:7546 | jq
Run Code Online (Sandbox Code Playgroud)
错误是:
{
"jsonrpc": "2.0",
"id": "2",
"error": {
"code": -32602,
"name": "Invalid parameter",
"message": "[Request ID: 5fda4d4a-3160-4f8f-8ed3-51ad64dada46] Invalid parameter 0: Expected 0x prefixed string representing the hash (32 bytes) of a transaction, value: 0x89eb7e219df6f8b3b3406c8a3698d5b484a4945059af643861c878e41ffc161b2589cc82ff40b4392ceb53856c5252c1"
}
Run Code Online (Sandbox Code Playgroud)
如何获得可在 RPC 中使用的交易哈希?
CONTRACT_REVERT_EXECUTED
不知道我做错了什么,但我正在尝试调用一个函数,它接受一个参数,我确保它是正确的,但它仍然会恢复。这是使用 HederaTokenService 的 hedera-hashgraph。
智能合约:
pragma solidity ^0.8.11;
import "./hip-206/HederaTokenService.sol";
import "./hip-206/HederaResponseCodes.sol";
contract Minting is HederaTokenService {
address tokenAddress;
bytes metadata;
string baseURI = "abc";
uint64 mintPrice;
function mintNonFungibleToken(uint64 _amount) external payable {
bytes[] memory nftMetadatas = generateBytesArrayForHTS(
baseURI,
_amount
);
(
int256 response,
uint64 newTotalSupply,
) = HederaTokenService.mintToken(tokenAddress, _amount, metadata);
if (response != HederaResponseCodes.SUCCESS) {
revert("Mint Failed");
}
}
// @dev Helper function which generates array of addresses required for HTSPrecompiled
function generateAddressArrayForHTS(address _address, uint256 _items)
internal
pure …Run Code Online (Sandbox Code Playgroud) hashgraph ×3
hedera ×2
blockchain ×1
ecdsa ×1
javascript ×1
mnemonics ×1
node.js ×1
rpc ×1
solidity ×1