blockchain:静的htmlからipfsにファイルをアップロードする
文書の過去の版を表示しています。
静的HTMLからIPFSにファイルをアップロードする
静的HTMLで HTML の FILE API で指定されたファイルを IPFS にアップロードする機能を実現します。
静的 HTML の作成
> mkdir simple_web > cd simple_web simple_web> code IPFSUploader.html
require("@nomiclabs/hardhat-waffle");
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
// Go to https://www.alchemyapi.io, sign up, create
// a new App in its dashboard, and replace "KEY" with its key
const ALCHEMY_API_KEY = "m4NR445U7JhjZ5gYddoeaQ15KFaiTslL";
// Replace this private key with your Goerli account private key
// To export your private key from Metamask, open Metamask and
// go to Account Details > Export Private Key
// Be aware of NEVER putting real Ether into testing accounts
const GOERLI_PRIVATE_KEY = "4f350473ad3e2ae66dd8d9afc545b64c7ab1cff5fb610bbe6e2ab95189d62c05";
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.4",
networks: {
hardhat: {},
goerli: {
url: `https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
accounts: [`${GOERLI_PRIVATE_KEY}`]
}
}
};
blockchain/静的htmlからipfsにファイルをアップロードする.1655184620.txt.gz · 最終更新: by dot
