質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Solidity

Solidityは、仮想通貨イーサリアム上で実行できるプログラミング言語。スマートコントラクトやDAppsなどの開発・実装に用いられます。コントラクト指向・高水準な言語のため、イーサリアム上で動作するEVM Codeに翻訳することが可能です。

Ethereum

Ethereum(イーサリアム)は、ビットコインに次いで時価総額が大きい仮想通貨もしくはそのブロックチェーン技術を指します。DApps やスマート・コントラクトの構築を目的としたプラットフォームであり、OSSで開発されています。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

0回答

1390閲覧

HardhatにてERC721デプロイの際のエラーが解決できません。

Taka_Yoshi

総合スコア2

Solidity

Solidityは、仮想通貨イーサリアム上で実行できるプログラミング言語。スマートコントラクトやDAppsなどの開発・実装に用いられます。コントラクト指向・高水準な言語のため、イーサリアム上で動作するEVM Codeに翻訳することが可能です。

Ethereum

Ethereum(イーサリアム)は、ビットコインに次いで時価総額が大きい仮想通貨もしくはそのブロックチェーン技術を指します。DApps やスマート・コントラクトの構築を目的としたプラットフォームであり、OSSで開発されています。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

0クリップ

投稿2021/08/02 11:13

現在以下の記事を参考に、ERC721の開発を試みています。

https://blog.opensphere.co.jp/posts/dapps003

●環境
vagrant - ubuntu
Hardhat(Solidity)
Openzeppelin

以下のコマンドでデプロイをしようとするとエラーが出るのですが、解決できません。

$ npx hardhat deploy --network online

**Error: ERROR processing /vagrant_data/testnft/deploy/MyERC721.ts:

TypeError: Cannot read property 'toString' of undefined**
at DeploymentsManager.onPendingTx (/vagrant_data/testnft/node_modules/hardhat-deploy/src/DeploymentsManager.ts:503:35)
at _deploy (/vagrant_data/testnft/node_modules/hardhat-deploy/src/helpers.ts:588:16)
at _deployOne (/vagrant_data/testnft/node_modules/hardhat-deploy/src/helpers.ts:768:16)
at Object.deploy [as func] (/vagrant_data/testnft/deploy/MyERC721.ts:19:22)
at DeploymentsManager.executeDeployScripts (/vagrant_data/testnft/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1049:22)
at DeploymentsManager.runDeploy (/vagrant_data/testnft/node_modules/hardhat-deploy/src/DeploymentsManager.ts:885:5)
at Environment._runTaskDefinition (/vagrant_data/testnft/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14)
at Environment.run (/vagrant_data/testnft/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:14)
at SimpleTaskDefinition.action (/vagrant_data/testnft/node_modules/hardhat-deploy/src/index.ts:528:32)
at Environment._runTaskDefinition (/vagrant_data/testnft/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14)
at DeploymentsManager.executeDeployScripts (/vagrant_data/testnft/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1052:19)

関係するソースは以下の通りです。

contracts/MyERC721.sol

pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol"; contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } contract MyERC721 is ERC721PresetMinterPauserAutoId { address proxyRegistryAddress; constructor( address _proxyRegistryAddress, string memory _name, string memory _symbol, string memory _baseTokenURI ) ERC721PresetMinterPauserAutoId(_name, _symbol, _baseTokenURI) { proxyRegistryAddress = _proxyRegistryAddress; } function isApprovedForAll(address _owner, address _operator) public override view returns (bool) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(_owner)) == _operator) { return true; } return super.isApprovedForAll(_owner, _operator); } }

deploy/MyERC721.ts

import {HardhatRuntimeEnvironment} from 'hardhat/types'; import {DeployFunction} from 'hardhat-deploy/types'; import assert from "assert"; assert(process.env.PROXY_REGISTRY_ADDRESS); assert(process.env.TOKEN_NAME); assert(process.env.TOKEN_SYMBOL); assert(process.env.TOKEN_BASE_URI); const deploy: DeployFunction = async function ({ getNamedAccounts, deployments, getChainId, getUnnamedAccounts }: HardhatRuntimeEnvironment) { const { deploy, execute } = deployments; const { deployer } = await getNamedAccounts(); const MyERC721 = await deploy("MyERC721", { from: deployer, args: [process.env.PROXY_REGISTRY_ADDRESS, process.env.TOKEN_NAME, process.env.TOKEN_SYMBOL, process.env.TOKEN_BASE_URI], log: true, }) console.log('MyERC721: ' + MyERC721.address); await execute('MyERC721', {from: deployer}, 'mint', deployer); } export default deploy;

node_modules/hardhat-deploy/src/DeploymentsManager.ts

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async onPendingTx( tx: TransactionResponse, name?: string, // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types deployment?: any ): Promise<TransactionResponse> { if ( this.db.writeDeploymentsToFiles && this.network.saveDeployments && this.db.savePendingTx ) { const deployFolderPath = path.join( this.deploymentsPath, this.deploymentFolder() ); console.log("tx", tx.hash); const pendingTxPath = path.join(deployFolderPath, '.pendingTransactions'); fs.ensureDirSync(deployFolderPath); const rawTx = tx.raw; console.log(tx); const decoded = tx.raw ? undefined : { from: tx.from, gasPrice: tx.gasPrice.toString(), gasLimit: tx.gasLimit.toString(), to: tx.to, value: tx.value.toString(), nonce: tx.nonce, data: tx.data, r: tx.r, s: tx.s, v: tx.v, // creates: tx.creates, // TODO test chainId: tx.chainId, }; this.db.pendingTransactions[tx.hash] = name ? {name, deployment, rawTx, decoded} : {rawTx, decoded}; fs.writeFileSync( pendingTxPath, JSON.stringify(this.db.pendingTransactions, null, ' ') ); // await new Promise(r => setTimeout(r, 20000)); const wait = tx.wait.bind(tx); tx.wait = async () => { const receipt = await wait(); // console.log("checking pending tx..."); delete this.db.pendingTransactions[tx.hash]; if (Object.keys(this.db.pendingTransactions).length === 0) { fs.removeSync(pendingTxPath); } else { fs.writeFileSync( pendingTxPath, JSON.stringify(this.db.pendingTransactions, null, ' ') ); } return receipt; }; } return tx; }

恐らくDeploymentsManager.tsのonPendingTx関数内のtxが未定義なのだと思いますが、解決方法がわかりません。

よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問