I am following the Upload to Arweave example from Solana Cookbook:
This used to work perfectly, but has stopped recently and now returns an HTTP 400 error and:
{
"error": "Nodes rejected the TX headers"
}
as the response body.
import { promises as fs } from "fs";
import { SECONDS } from "./constants";
import Arweave from "arweave";
import { fileNameToContentType } from "./solana-functions";
import { log, stringify } from "./functions";
const OK = 200;
// See https://solanacookbook.com/references/nfts.html#upload-to-arweave
export const uploadImageToArweave = async (fileName: string) => {
const data = await fs.readFile(fileName);
const arweave = Arweave.init({
host: "arweave.net",
port: 443,
protocol: "https",
timeout: 20 * SECONDS,
logging: true,
});
const contentType = fileNameToContentType(fileName);
const arWeaveWallet = JSON.parse(
// File supplied by https://faucet.arweave.net/
await fs.readFile("arweave-wallet.json", "utf-8")
);
const transaction = await arweave.createTransaction({
data,
});
transaction.addTag("Content-Type", contentType);
await arweave.transactions.sign(transaction, arWeaveWallet);
const response = await arweave.transactions.post(transaction);
if (response.status !== OK) {
log(stringify(response.data));
throw new Error(`Got ${response.status} error from arWeave`);
}
const uploadedImageUrl = `https://arweave.net/${transaction.id}`;
return uploadedImageUrl;
};
I can't find anything about this error - literally 0 results - using the most popular search engine.
How can I upload something to ARweave successfully?