您正在查看: Ethereum-新手教程 分类下的文章

How to check if Ethereum address is valid or not

web3.js

const address = "0x0089d53F703f7E0843953D48133f74cE247184c2"
let result = Web3.utils.isAddress(address)
console.log(result)  // => true

web3j

社区fork为其增加了isAddress commit
https://github.com/bcskill/web3j

package org.web3j.utils;

import org.junit.Test;

import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertTrue;

import static org.web3j.utils.Account.isAddress;

public class AccountTest {
    @Test
    public void verifyIsAddress() {
        String validLowerCaseAddress = "0x3de8c14c8e7a956f5cc4d82beff749ee65fdc358";
        assertTrue(isAddress(validLowerCaseAddress));
        String validChecksumAddress = "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359";
        assertTrue(isAddress(validChecksumAddress));
        String invalidLengthAddress = "0x3de8c14c8e7a956f5cc4d82beff749ee65bac35";
        assertFalse(isAddress(invalidLengthAddress));
        String invalidChecksumAddress = "0x3de8c14c8E7a956f5cc4d82beff749ee65fdc358";
        assertFalse(isAddress(invalidChecksumAddress));
    }
} 

参考

https://piyopiyo.medium.com/how-to-check-if-ethereum-address-is-valid-or-not-ef587b6c4819
https://github.com/assafY/web3j.git

Swarm bee 开启mainnet方法

mainnet: true
network-id: 1
full-node: true
debug-api-enable: true
swap-enable: true
swap-endpoint: https://rpc.xdaichain.com
welcome-message: "https://www.bcskill.com"
db-open-files-limit: "500"
swap-initial-deposit: 0
verbosity: trace

api-addr: :1633
debug-api-addr: :1635
p2p-addr: :1634

https://discord.com/channels/799027393297514537/810905662375854123/856719763454296094

从哪里获得xDai代币

由于Swarn正式线基于xDai以太坊侧链运行,因为启动需要部署支票合约,所以需要拥有一定量的xDai

此片文章只讨论Swarm技术问题,社区不推荐任何虚拟币购买和交易

直接兑换

https://bitmax.io/en/basic/cashtrade-spottrading/usdt/xdai

跨链过去DAI->XDAI

可以直接GM DAI https://www.huobi.com/en-us/exchange/dai_usdt/ 然后 直接跨链过去 https://bridge.xdaichain.com/

添加到MetaMask

网络名称:xDai
新的RPC网址:https://rpc.xdaichain.com/
链 ID:0x64
符号:xDai
区块浏览器网址:https://blockscout.com/xdai/mainnet
https://www.xdaichain.com/for-users/wallets/metamask/metamask-setup#setting-up-metamask-for-xdai

参考文档

https://www.xdaichain.com/for-users/get-xdai-tokens#how-to-get-xdai-stable-tokens

xdai RPC搭建

下载openethereum

此时最新release版本v3.2.6
https://github.com/openethereum/openethereum/releases/tag/v3.2.6

根据对应系统下载对应版本程序
社区使用的是linux,对应的地址是

wget https://github.com/openethereum/openethereum/releases/download/v3.2.6/openethereum-linux-v3.2.6.zip
unzip -x openethereum-linux-v3.2.6.zip
chmod +x openethereum

运行openethereum

nohup ./openethereum --chain xdai --db-path ./data --base-path ./base_data --interface all --port 19000 --jsonrpc-interface all --jsonrpc-port 19001 --ws-port 19002 --ws-interface all>./node.log 2>&1 &

查看日志

tail -f node.log

xdai区块浏览器

https://blockscout.com/xdai/mainnet/

参考

https://openethereum.github.io/Configuring-OpenEthereum
https://www.xdaichain.com/for-developers/install-xdai-client/parity