
中文:ERC4337 详解之:Account Creation
与传统意义上的钱包账户不同, AA账户本身实现了账户和签名器的分离,所以钱包地址不再是我们理解的签名器的地址,而是一个专门的账户地址,而且值得注意的是,这个账户地址因为是一个智能合约,所以他需要被部署到区块链上才能使用。但幸运的是,ERC4337定义了标准,让账户地址在账户只能合约部署之前就能得到。 这篇文章讲详细解释ERC 4337账户的创建以及部署:账户创建账户的创的目的是得到一个账户地址。整个过程需要一下模块的交互: 账户工厂:账户工厂的作用是用来创建账户的,但往往创建过程不是直接的账户工厂的调用。账户工厂未来保证创建账户地址的可预测性,会使用CREATE2方法来创建 Example:他需要一下步骤来完成:getAccountInitCode:通过链接账户得到账户工厂的address,以及账户工厂账户创建的callData,把这两个数据组合到一起得到账户initCode调用EntryPoint → getSenderAddress,传入initCode,getSenderAddress内部会解析这个initCode,并且解析工厂合约的地址和callData,用call方法来...
DApp: Use Wallet to perform the transaction
When writing DApp, we often need Wallet like Metamask to interact with the user to perform any Transactions(Like send Eth to an address) The following diagram explains the whole process of how the User use DApp to connect to the Wallet and perform the TransactionsSequence DiagramProcess ExplainConnected to the Wallet Before performing the transaction, the user has to connect to the wallet to ensure that he/she has the ability to execute any transactionWhen User use App to connect to the walle...
How to get the most accurate token supply information
Coin market cap and Coingecko are the 2 largest cryptocurrency information websites. When evaluating a coin or token, we often need to check the token matrics like total supply, distribution from those websites. If you stay long enough, you will find that some coin’s market cap information differs from one to another. For example, the total supply of token Wonderland is different from Coin market cap and coin gecko.Coin Market CapCoin GeckoThen you might ask, which one is correct or how could...

中文:ERC4337 详解之:Account Creation
与传统意义上的钱包账户不同, AA账户本身实现了账户和签名器的分离,所以钱包地址不再是我们理解的签名器的地址,而是一个专门的账户地址,而且值得注意的是,这个账户地址因为是一个智能合约,所以他需要被部署到区块链上才能使用。但幸运的是,ERC4337定义了标准,让账户地址在账户只能合约部署之前就能得到。 这篇文章讲详细解释ERC 4337账户的创建以及部署:账户创建账户的创的目的是得到一个账户地址。整个过程需要一下模块的交互: 账户工厂:账户工厂的作用是用来创建账户的,但往往创建过程不是直接的账户工厂的调用。账户工厂未来保证创建账户地址的可预测性,会使用CREATE2方法来创建 Example:他需要一下步骤来完成:getAccountInitCode:通过链接账户得到账户工厂的address,以及账户工厂账户创建的callData,把这两个数据组合到一起得到账户initCode调用EntryPoint → getSenderAddress,传入initCode,getSenderAddress内部会解析这个initCode,并且解析工厂合约的地址和callData,用call方法来...
DApp: Use Wallet to perform the transaction
When writing DApp, we often need Wallet like Metamask to interact with the user to perform any Transactions(Like send Eth to an address) The following diagram explains the whole process of how the User use DApp to connect to the Wallet and perform the TransactionsSequence DiagramProcess ExplainConnected to the Wallet Before performing the transaction, the user has to connect to the wallet to ensure that he/she has the ability to execute any transactionWhen User use App to connect to the walle...
How to get the most accurate token supply information
Coin market cap and Coingecko are the 2 largest cryptocurrency information websites. When evaluating a coin or token, we often need to check the token matrics like total supply, distribution from those websites. If you stay long enough, you will find that some coin’s market cap information differs from one to another. For example, the total supply of token Wonderland is different from Coin market cap and coin gecko.Coin Market CapCoin GeckoThen you might ask, which one is correct or how could...

Subscribe to B+

Subscribe to B+
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
decimals 本身是小数的意思,在区块链的ERC20的智能合约里边,也存在一个只读的decimals的方法。这个方法一般返回的是一个小于18的整数。为什么需要这个方法,他设计的初衷是什么,以及如何运用是这篇文章将要探讨的主题
他的作用是能将token分成任意小份。假设有一个Token叫PAI, 小明有3个PAI,想转账1.5个PAI给小红,自己留1.5个。这样的操作在solidity语言中是不被支持的。因为solidity只支持整数,所以你就只能转1或则2,不能转1.5个token
而ERC20里边定义decimals就是为了解决这一问题。如上边例子,如果PAI想要支持转账小数位后1位,那么他会将decimal就可以设置为1,那么余额的30就代表有3个PAI。这种情况下,小明可以转15给小红,也就实现了转1.5个PAI token
在Ethereum里,USDT的decimals是6,也就是说USDT支持最多小数点后六位的转账

我们也找到了有6位数小数点的转账
https://etherscan.io/tx/0x543c3e23073b339d3aa17a252b275b57ba158542d1997928c3cd259023506688
在这笔转账中,转的token是213.778057个USDT

而我们查看转账的log会发现,这笔钱是以213778057转入的

如果这个ERC20的智能合约接受的value是这样的格式,那当我调用ERC20 smart contract的transfer方法的时候,我如何知道并把我想要转账的金额呢,下边的代码可以帮你解决这个问题:
import ethers from 'ethers';
const transferAmount = 2.12;
const decimals = await ERC20.decimals(); // 6
const value = ethers.utils.parseUnits(transferAmount, decimals); // 2120000
// when want to convert the transfer value to the token amount:
ethers.utils.formatUnits(value, decimals) // 2.12
decimals 本身是小数的意思,在区块链的ERC20的智能合约里边,也存在一个只读的decimals的方法。这个方法一般返回的是一个小于18的整数。为什么需要这个方法,他设计的初衷是什么,以及如何运用是这篇文章将要探讨的主题
他的作用是能将token分成任意小份。假设有一个Token叫PAI, 小明有3个PAI,想转账1.5个PAI给小红,自己留1.5个。这样的操作在solidity语言中是不被支持的。因为solidity只支持整数,所以你就只能转1或则2,不能转1.5个token
而ERC20里边定义decimals就是为了解决这一问题。如上边例子,如果PAI想要支持转账小数位后1位,那么他会将decimal就可以设置为1,那么余额的30就代表有3个PAI。这种情况下,小明可以转15给小红,也就实现了转1.5个PAI token
在Ethereum里,USDT的decimals是6,也就是说USDT支持最多小数点后六位的转账

我们也找到了有6位数小数点的转账
https://etherscan.io/tx/0x543c3e23073b339d3aa17a252b275b57ba158542d1997928c3cd259023506688
在这笔转账中,转的token是213.778057个USDT

而我们查看转账的log会发现,这笔钱是以213778057转入的

如果这个ERC20的智能合约接受的value是这样的格式,那当我调用ERC20 smart contract的transfer方法的时候,我如何知道并把我想要转账的金额呢,下边的代码可以帮你解决这个问题:
import ethers from 'ethers';
const transferAmount = 2.12;
const decimals = await ERC20.decimals(); // 6
const value = ethers.utils.parseUnits(transferAmount, decimals); // 2120000
// when want to convert the transfer value to the token amount:
ethers.utils.formatUnits(value, decimals) // 2.12
No activity yet