web3.eth.accounts.wallet.remove - 从钱包中移除指定账户

优质
小牛编辑
127浏览
2023-12-01

从钱包中移除一个账户。

调用:

web3.eth.accounts.wallet.remove(account);

参数:

account - String|Number: 账户地址,或在钱包中的索引

返回值:

Boolean: 移除成功则返回true,否则返回false

示例代码:

web3.eth.accounts.wallet;
> Wallet {
    0: {...},
    "0xF0109fC8DF283027b6285cc889F5aA624EaC1F55": {...}
    1: {...},
    "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01": {...}
    ...
}

web3.eth.accounts.wallet.remove('0xF0109fC8DF283027b6285cc889F5aA624EaC1F55');
> true

web3.eth.accounts.wallet.remove(3);
> false