简体   繁体   English

如何使ERC20代币持有者的钱包地址保密?

[英]How to keep wallet address of an ERC20 token holder private?

This is the interface that is required for a token to be an ERC20 token 这是令牌成为ERC20令牌所需的接口

contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address tokenOwner) public constant returns (uint balance);
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);

    event Transfer(address indexed from, address indexed to, uint tokens);
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}

I want to keep private the address of who owns my token. 我想将谁拥有我的令牌的地址保密。 So I deleted the Transfer event and the Approval event. 因此,我删除了转移事件和批准事件。 I also made the balanceOf function private. 我还把balanceOf函数设为私有。

Is there still some way for a public person to find out who owns one of my tokens? 公众人士还可以通过某种方式找出谁拥有我的代币之一? Also is there some way for a public person to know when a trade has taken place? 公共人士还可以通过某种方式知道何时进行交易?

Yes, one of the major features of Bitcoin and Ethereum are that they are public. 是的,比特币和以太坊的主要特征之一是它们是公开的。 When anyone uses your smart contract, all their actions are recorded, necessarily and by design, in the blockchain. 当任何人使用您的智能合约时,他们的所有行为必定会有计划地记录在区块链中。

See this tx which called a smart contract method. 请参阅此称为智能合约方法的TX Notice how I can see who sent what to whom, what function was called, and with what parameters. 注意我如何看到谁向谁发送了什么,调用了什么函数以及带有什么参数。

Is it private? 它是私人的吗?

No 没有

Is there still some way for a public person to find out who owns one of my tokens? 公众人士还可以通过某种方式找出谁拥有我的代币之一? Also is there some way for a public person to know when a trade has taken place? 公共人士还可以通过某种方式知道何时进行交易?

The storage of the contract can be inspected, and the transaction data can be inspected. 可以检查合同的存储,也可以检查交易数据。 This data is necessarily public. 此数据必须是公开的。 The best you can do is make it harder for your median user to find this information (although the people who know what they're doing could dig it out and then publish it). 您能做的最好的事情就是使您的中级用户更难找到此信息(尽管知道自己在做什么的人可以将其挖掘出来然后发布)。

Is it an ERC20 token? 它是ERC20代币吗?

No 没有

This is the interface that is required for a token to be an ERC20 token... I deleted the Transfer event and the Approval event. 这是令牌成为ERC20令牌所需的接口...我删除了Transfer事件和Approval事件。 I also made the balanceOf function private. 我还把balanceOf函数设为私有。

Note that deleting those things makes it not an ERC20 token anymore. 请注意,删除这些内容将使其不再是ERC20令牌。 Those are required in the ERC20 spec . 这些在ERC20规范中是必需的。

What now? 现在怎么办?

Transactions that are private on a public blockchain is an ongoing area of research. 公共区块链上的私人交易是一个持续的研究领域。 If you really want to implement this, it will take diving into the current research in the space, getting familiar with things like ZK-SNARKS and alternatives. 如果您真的想实现此目标,则需要深入研究该领域的最新研究,并熟悉ZK-SNARKS和替代产品。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM