- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 web3 功能添加到我的 svelte 应用程序中,但在导入 web3 模块时遇到问题。这是我的 package.json 供引用:
{
"version": "0.0.1",
"type": "module",
"scripts": {
"test": "mocha",
"start": "PORT=3000 node build/",
"dev": "svelte-kit dev",
"dev-host": "svelte-kit dev --host",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"devDependencies": {
"@sveltejs/adapter-node": "^1.0.0-next.55",
"@sveltejs/kit": "next",
"@types/cookie": "^0.4.1",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"dayjs": "^1.10.4",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.1",
"js-yaml": "^3.14.1",
"jsonwebtoken": "^8.5.1",
"password-hash": "^1.2.2",
"prettier": "^2.4.1",
"prettier-plugin-svelte": "^2.4.0",
"rehype-highlight": "^4.1.0",
"rehype-stringify": "^8.0.0",
"remark-frontmatter": "^3.0.0",
"remark-gfm": "^1.0.0",
"remark-parse": "^9.0.0",
"remark-rehype": "^8.0.0",
"sass": "^1.0.0",
"svelte": "^3.34.0",
"svelte-check": "^2.2.6",
"svelte-preprocess": "^4.9.4",
"to-vfile": "^6.1.0",
"tslib": "^2.3.1",
"typescript": "^4.4.3",
"unified": "^9.2.1",
"vite": "^2.1.0",
"mocha": "^9.1.2"
},
"dependencies": {
"@fontsource/fira-mono": "^4.5.0",
"better-sqlite3": "^7.4.4",
"cookie": "^0.4.1",
"solc": "^0.4.17",
"web3": "^1.6.0",
"@truffle/hdwallet-provider": "^1.5.1",
"fs-extra": "^10.0.0",
"ganache-cli": "^6.12.2"
}
}
我基本上是在尝试根据地址获取契约(Contract)
import web from './web3';
import Contract from './build/Contract.json';
export default (address) => {
return new web.eth.Contract(
JSON.parse(Contract.interface),
address
);
};
在我的 component.svelte 中我这样做:
<script>
import Contract from "../../../etherum/contract.js";
</script>
这给了我以下错误:
util.js:109 Uncaught (in promise) ReferenceError: process is not defined
at node_modules/util/util.js (util.js:109)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at node_modules/web3-core-requestmanager/lib/index.js (index.js:20)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at node_modules/web3-core/lib/index.js (index.js:22)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at node_modules/web3/lib/index.js (index.js:29)
at __require2 (chunk-VPFHXPC5.js?v=bd5ef6bd:36)
at dep:web3:1
node_modules/util/util.js @ util.js:109
__require2 @ chunk-VPFHXPC5.js?v=bd5ef6bd:36
node_modules/web3-core-requestmanager/lib/index.js @ index.js:20
__require2 @ chunk-VPFHXPC5.js?v=bd5ef6bd:36
node_modules/web3-core/lib/index.js @ index.js:22
__require2 @ chunk-VPFHXPC5.js?v=bd5ef6bd:36
node_modules/web3/lib/index.js @ index.js:29
__require2 @ chunk-VPFHXPC5.js?v=bd5ef6bd:36
(anonymous) @ dep:web3:1
await in (anonymous) (async)
(anonymous) @ (index):273
以下在 React 组件中进行导入的方法适用于此代码:
import Contract from "../../ethereum/contract";
static async getInitialProps(props) {
const campaign = Contract(props.query.address);
React 与 sveltekit 处理此问题的方式有何不同?
我该如何解决这个问题?
最佳答案
我试图通过(vite 驱动的)sveltekit 中的 process.env.MYVAR
使用 secret 的 dotenv 环境变量应用程序,并了解到现在在 sveltekit 中执行此操作的正确方法是 import { env } from '$env/dynamic/private';
并且只能在 +page.server.js
file's PageServerLoad()
function 内访问它
关于ethereum - slim 和 web3- ReferenceError : process is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70618737/
.net 4.0 添加了几个与线程相关的新类:ManualResetEventSlim , SemaphoreSlim和 ReaderWriterLockSlim . Slim 版本和旧类之间有什么区
一个新的 Slim 问题 我期待以下 Slim 模板 div class="header" h2 slim head p a test example of span Slim span a
我们正在考虑使用 Slim 3 作为我们 API 的框架。我已经搜索过 SO 和 Slim 文档,但找不到问题的答案。如果我们有不同的路由文件(例如 v1、v2 等)并且如果两个路由具有相同的签名,则
我正在尝试在 Slim-lang 的列表项中嵌套第二个 ul,如下所示: div.row ul.dropdown li Dropdown Option 1
我有以下代码导致 Slim::Parser::SyntaxError : p code.inline /charge 我希望这会输出 /charge但这只会让斯林姆不高兴。 为什么? 最佳答案 使
我想在子目录中使用 Slim 3,但似乎无法加载它。所有文件都包含在子目录中,包括 composer.json。这是我的 composer.json: "require": { "slim/s
我的 Slim 项目组织如下: - app -- Acme --- Auth ---- Auth.php (handles authentication) -- config --- developm
我在我的 svelte-typescript 项目上使用 clickOutside 指令,当我将自定义事件分配给相关元素时出现此错误 Type '{ class: string; onclick_ou
我们缩小了在 Silex 和 Slim PHP 框架之间的搜索范围,以便在我们的 Apache/PHP/MySQL 服务器上路由我们的 REST API。 两者似乎都有很好的评价。 Silex 可能有
我有一个 get表格中的路线 $app->get('/redirect[/{subject}]', function ($request, $response, $args) { }); 如果我向 /
任何人都可以解释在选择使用钩子(Hook)而不是使用中间件来实现身份验证或缓存等功能时是否有任何显着的优点或缺点? 例如 - 我可以通过自定义中间件获取请求对象并设置应用程序语言变量来实现翻译功能,该
在 Slim 3 中是否有类似 Laravel 的 back() helper 来获取之前的路由名称或 uri? 它不必特定于 Slim,我只是想重定向回上一页。 谢谢:) 最佳答案 假设你想要 re
在 Slim 3 中是否有类似 Laravel 的 back() helper 来获取之前的路由名称或 uri? 它不必特定于 Slim,我只是想重定向回上一页。 谢谢:) 最佳答案 假设你想要 re
我正在学习这里的教程: https://www.simplifiedcoding.net/php-restful-api-framework-slim-tutorial-1/ 导师说下载slim在:
如何从不同的 php 页面中的另一个函数调用 slim 函数 这里是 My.php: $app->get('/list/:id',function($id) { //fill array her
很抱歉提出这样一个愚蠢的问题,但在文档中找不到它: filename.slim filename.html.slim 这似乎是一种非常适合使用的语言。我以前使用过 HAML,所以我认为这将是一个相当不
请原谅我的无知,但我只是使用 npm 安装了 jQuery,并且在 jQuery 文件之间有一个名为 jquery.slim.js 的文件,slim 是什么?我知道 min 代表缩小但 slim 对我
TailwindCSS 看起来像是一个很棒的前端工具,但我想知道如何将它与 Rails Slim 模板语言一起使用? 例如: 如果我通过 HTML2SLIM 运行它,我会得到这个建议: .bg-re
TailwindCSS 看起来像是一个很棒的前端工具,但我想知道如何将它与 Rails Slim 模板语言一起使用? 例如: 如果我通过 HTML2SLIM 运行它,我会得到这个建议: .bg-re
我想将纤薄的 textmate 包安装到 sublime2。 我去了这个链接 slim textmate bundle 我将它克隆到 pristinepackage(根据 nettuts 网站),但什
我是一名优秀的程序员,十分优秀!