小编Jas*_*ran的帖子

npm 为以太坊开发安装 truffle 时出错

当我尝试使用安装 truffle 时npm,会出现以下输出:

npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

npm WARN deprecated har-validator@5.1.5: this library is no longer supported

npm WARN deprecated multicodec@0.5.7: stable api reached

npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated

npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to …
Run Code Online (Sandbox Code Playgroud)

linux npm-install truffle

4
推荐指数
1
解决办法
6299
查看次数

坚固性:从具有相同 msg.sender 的另一个合约调用合约函数

我有一个函数需要调用另一个合约上的传输方法。我希望从原始调用者的地址而不是合约中调用转移方法。是否可以?

这是代码:

function buyGameBundle(string calldata id) external nonReentrant {
    structGameBundles  memory currentItem = _gameBundles[id];
    require(currentItem.exists == true, "bundle does not exists");
    require(currentItem.totalSupply > 0, "there are no more bundles left");
    if (currentItem.cost > 0) {
        erc20.transfer(_feesAccount, currentItem.cost);
    }
    currentItem.totalSupply = currentItem.totalSupply.sub(1);
    _gameBundles[id] = currentItem;
    emit BuyGameBundle(_msgSender(), id, currentItem.cost);
}
Run Code Online (Sandbox Code Playgroud)

ethereum solidity

3
推荐指数
1
解决办法
7704
查看次数

如何在 Tailwind css 中居中显示项目

如何在 Tailwind 中将小尺寸的内容或项目居中。我做了 Tailwind 中可用的所有对齐类,但它不起作用。这是顺风V3

<div class="bg-white pb-8">
  <div class="p-4 pb-0 bg-third-bg sm:max-w-7xl mx-auto">
    <div class="sm:flex sm:max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 sm:items-center sm:justify-between bg-white p-6">
      <div class="sm:flex sm:flex-col sm:items-center sm:justify-center sm:space-y-4 md:w-4/12">
        <div class="sm:flex">
          <img src="https://educlever.beplusthemes.com/university/wp-content/uploads/2018/11/forma4.png" alt="" />
        </div>
        <div class="sm:flex text-xl font-bold">Lorem ipsum dolor sit</div>
        <div class="sm:flex sm:text-center">Lorem ipsum dolor sit amet, conse ct amet, conse adipiscing elit dolor sit a amet, conse adipisci</div>
      </div>
      <div class="sm:flex sm:flex-col sm:items-center sm:justify-center sm:space-y-4 md:w-4/12">
        <div class="sm:flex">
          <img src="https://educlever.beplusthemes.com/university/wp-content/uploads/2018/11/forma3.png" alt="" />
        </div> …
Run Code Online (Sandbox Code Playgroud)

tailwind-css tailwind-3

3
推荐指数
1
解决办法
2万
查看次数

C# using 语句位于代码页顶部

几乎所有 C# 文件using在页面顶部都有语句

IE

using System;
using System.IO;

//code....
Run Code Online (Sandbox Code Playgroud)

using页面顶部的语句是什么意思?为什么语法与其他using语句声明不同。

IE

using (ResourceType resource = expression) statement
Run Code Online (Sandbox Code Playgroud)

.net c#

2
推荐指数
1
解决办法
3892
查看次数

如何使用 Ether.js 转移 ERC20 代币?

我正在尝试在 Hardhat 中测试我的智能合约,但为了做到这一点,我首先需要向我的合约发送一些 ERC20 代币(对于此测试,我使用 USDC)。

在我的测试中,我模拟了 USDC 鲸鱼,但如何实际将 USDC 转移到我的合约中?

it("USDC test", async function () {
    const testContract =
        await ethers.getContractFactory("TestContract")
            .then(contract => contract.deploy());
    await testContract.deployed();

    // Impersonate USDC whale
    await network.provider.request({
        method: "hardhat_impersonateAccount",
        params: [USDC_WHALE_ADDRESS],
    });
    const usdcWhale = await ethers.provider.getSigner(USDC_WHALE_ADDRESS);

    // Need to transfer USDC from usdcWhale to testContract
});
Run Code Online (Sandbox Code Playgroud)

blockchain ethereum erc20 ethers.js hardhat

1
推荐指数
1
解决办法
7601
查看次数

Ethers.js:如何将地址数组编码到 Solidity 字节变量中?

我正在使用 Ether.js 测试我的 Solidity 代码,并且被测试的方法需要一个bytes参数,我用它来传递地址数组:

function testFunction(bytes calldata params) external {
   address[] memory addresses = abi.decode(params, (address[]));
}
Run Code Online (Sandbox Code Playgroud)

如何在 Ethers.js 中对地址数组进行编码,以便可以将其作为参数传递?

encode solidity ethers.js

1
推荐指数
1
解决办法
1万
查看次数

在 useState() 中从数组中删除项目

我正在学习反应。需要一些帮助才能理解这一点。

我有两个按钮。一个是“添加随机文本”,另一个是“删除”。

对于添加按钮,我用来Math.random生成数字并添加一些文本。

我想通过映射来显示列表项。当单击删除按钮时,最后一个项目将被删除。

我尝试过pop(),但只显示已删除的那个。我怎样才能保留整个列表并删除最后一个?

const [data, setData]=useState([]);
let addHandler =()=>{
//Newdata is Math.random()*100+some text
setData([...data, newdata])
}
let removeHandler=()=>{

}
Run Code Online (Sandbox Code Playgroud)

reactjs react-hooks

0
推荐指数
1
解决办法
2573
查看次数