Giter Site home page Giter Site logo

web3swift-team / web3swift Goto Github PK

View Code? Open in Web Editor NEW
794.0 23.0 413.0 58.66 MB

Elegant Web3js functionality in Swift. Native ABI parsing and smart contract interactions.

License: Apache License 2.0

Ruby 0.05% Swift 36.25% C 13.67% JavaScript 49.82% Solidity 0.21%
web3 web3js web3-dapp dapp ethereum json-rpc smart-contracts cryptoswift crypto geth

web3swift's Introduction

web3swift

web3swift is an iOS toolbelt for interaction with the Ethereum network.

Social media

Join our discord or Telegram if you need support or want to contribute to web3swift development!

matter-github-swift Web3swift CI Swift Platform CocoaPods Compatible License Stackoverflow


Core features

  • ⚡ Swift implementation of web3.js functionality
  • 💭 Interaction with remote node via JSON RPC
  • 🔐 Local keystore management (geth compatible)
  • 🤖 Smart-contract ABI parsing
  • 🔓ABI decoding (V2 is supported with return of structures from public functions. Part of 0.4.22 Solidity compiler)
  • 🕸Ethereum Name Service (ENS) support - a secure & decentralised way to address resources both on and off the blockchain using simple, human-readable names
  • 🔄 Smart contracts interactions (read/write)
  • Infura support
  • Parsing TxPool content into native values (ethereum addresses and transactions) - easy to get pending transactions
  • 🖇 Event loops functionality
  • 🕵️‍♂️ Possibility to add or remove "middleware" that intercepts, modifies and even cancel transaction workflow on stages "before assembly", "after assembly" and "before submission"
  • Literally following the standards (BIP, EIP, etc):
    • BIP32 (HD Wallets), BIP39 (Seed phrases), BIP44 (Key generation prefixes)
  • EIP-20 (Standard interface for tokens - ERC-20), EIP-67 (Standard URI scheme), EIP-155 (Replay attacks protection), EIP-2718 (Typed Transaction Envelope), EIP-1559 (Gas Fee market change)
    • And many others (For details about this EIP's look at Documentation page): EIP-165, EIP-681, EIP-721, EIP-777, EIP-820, EIP-888, EIP-1155, EIP-1376, EIP-1400, EIP-1410, EIP-1594, EIP-1633, EIP-1643, EIP-1644, EIP-4361 (SIWE), ST-20
  • RLP encoding
  • Base58 encoding scheme
  • Formatting to and from Ethereum Units
  • Comprehensive Unit and Integration Test Coverage

Installation

Swift Package (Recommended)

The Swift Package Manager is a tool for automating the distribution of Swift code that is well integrated with Swift build system.

Once you have your Swift package set up, adding web3swift as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/web3swift-team/web3swift.git", .upToNextMajor(from: "3.0.0"))
]

Or if your project is not a package follow these guidelines on how to add a Swift Package to your Xcode project.

Example usage

In the imports section:

import web3swift
import Web3Core

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ sudo gem install cocoapods

To integrate web3swift into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'

target '<Your Target Name>' do
    use_frameworks!
    pod 'web3swift'
end

Then, run the following command:

$ pod install

WARNING: CocoaPods is a powerful tool for managing dependencies in iOS development, but it also has some limitations that preventing us of providing first class support there. We highly recommend using SPM first as using CocoaPods will delay new updates and bug fixes being delivered to you.

Send Ether

let transaction: CodableTransaction = .emptyTransaction
transaction.from = from ?? transaction.sender // `sender` one is if you have private key of your wallet address, so public key e.g. your wallet address could be interpreted
transaction.value = value
transaction.gasLimitPolicy = .manual(78423)
transaction.gasPricePolicy = .manual(20000000000)
web3.eth.send(transaction)

Contract read method

let contract = web3.contract(Web3.Utils.erc20ABI, at: receipt.contractAddress!)!
let readOp = contract.createReadOperation("name")!
readOp.transaction.from = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")
let response = try await readTX.callContractMethod()

Write Transaction and call smart contract method

let abiString = "[]" // some ABI string
let bytecode = Data.fromHex("") // some ABI bite sequence
let contract = web3.contract(abiString, at: nil, abiVersion: 2)!
let parameters: [Any] = [...]
let deployOp = contract.prepareDeploy(bytecode: bytecode, constructor: contract.contract.constructor, parameters: parameters)!
deployOp.transaction.from = "" // your address
deployOp.transaction.gasLimitPolicy = .manual(3000000)
let result = try await deployTx.writeToChain(password: "web3swift")

Sending network request to a node

func feeHistory(blockCount: UInt, block: BlockNumber, percentiles:[Double]) async throws -> Web3.Oracle.FeeHistory {
    let requestCall: APIRequest = .feeHistory(blockCount, block, percentiles)
    let response: APIResponse<Web3.Oracle.FeeHistory> = try await APIRequest.sendRequest(with: web3.provider, for: requestCall) /// explicitly declaring `Result` type is **required**.
    return response.result
}

Build from source

SPM

git clone https://github.com/web3swift-team/web3swift.git
cd web3swift
swift build

Requirements

  • iOS 13.0 / macOS 10.15
  • Xcode 12.5
  • Swift 5.5

Documentation

Documentation is under construction👷🏻👷🏼‍♀️. We’re trying our best to comment all public API as detailed as we can, but the end it still far to come. But in one of the nearest minor updates we’ll bring DocC support of already done amount of docs. And your PR in such are more than welcome.

Projects that are using web3swift

Please take a look at Our customers wiki page.

Support

Join our discord and Telegram if you need support or want to contribute to web3swift development!

Development

To do local development and run the local tests, we recommend to use ganache which is also used by CI when running github actions.

// To install
$ npm install ganache --global

// To run
$ ganache

This will create a local blockchain and also some test accounts that are used throughout our tests. Make sure that ganache is running on its default port 8546. To change the port in test cases locate LocalTestCase.swift and modify the static url variable.

Before you commit

We are using pre-commit to run validations locally before a commit is created. Please, install pre-commit and run pre-commit install from project's root directory. After that before every commit git hook will run and execute codespell, swiftlint and other checks.

Contribute

Want to improve? It's awesome: Then good news for you: We are ready to pay for your contribution via @gitcoin bot!

Contribution

  1. You are more than welcome to participate and get bounty by contributing! Your contribution will be paid via @gitcoin Grant program.
  2. Find or create an issue
  3. You can find open bounties in Gitcoin Bounties list
  4. Commita fix or a new feature in branch, push your changes
  5. Submit a pull request to develop branch
    1. Please, provide detailed description to it to help us proceed it faster.

@skywinder are charged with open-sourсe and do not require money for using web3swift library. We want to continue to do everything we can to move the needle forward.

Credits

Security Disclosure

If you believe you have identified a security vulnerability with web3swift, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue tracker.

License

web3swift is available under the Apache License 2.0 license. See the LICENSE for details.

web3swift's People

Contributors

6od9i avatar albertopeam avatar alex78pro avatar annayatsun1 avatar aranhaagency avatar baldyash avatar cclauss avatar chapiron avatar dsemenovsky avatar fesenkog avatar finestructure avatar hakumai-iida avatar iysbaera avatar izakpavel avatar janndriessen avatar jeneavranceanu avatar mloit avatar pharms-eth avatar podkovyrin avatar raviranjan-11 avatar rinat-enikeev avatar shamatar avatar skywinder avatar stavares843 avatar swiftylimi avatar vaishalidesai avatar valter4578 avatar yaroslavyaroslav avatar zhangliugang avatar zmgl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web3swift's Issues

Thread blocked

hello, when I call contract.method(_ method:, parameters: , extraData: , options: ), currentThread will be blocked.
I don't know why.

public func scrypt (password: String, salt: Data, length: Int, N: Int, R: Int, P: Int) -> Data? {
    guard let passwordData = password.data(using: .utf8) else {return nil}
    guard let deriver = try? Scrypt(password: passwordData.bytes, salt: salt.bytes, dkLen: length, N: N, r: R, p: P) else {return nil}

    guard let result = try? deriver.calculate() else {return nil}   
       
   //blocked in here,it's too slow precisely. I need to wait 5 minutes.

    return Data(result)
}
/////

Decouple address generation from key derivation in BIP32Keystore

web3swift is great, I'm gonna create hdwallet app based on web3swift. but I think BIP32 and BIP44 aimed to manager different blockchain addresses from single root seed, so It's better to separate address generation from key derivation。It‘s hard to extension from current implementation of BIP32Keystore.

eth.getAccounts() function returns an empty address Array

I involved this function on my private chain environment which is installed on mac that geth client. the json rpc interface about "eth_accounts" actually returns an address data. So I read the source found that a bug code, here it is:

guard let string = self.result as? [String] else {return nil} let values = string.compactMap { (str) -> EthereumAddress? in return EthereumAddress(str, ignoreChecksum: true) }
the ignoreChecksum parmas value if is ture, then the init function body will return nil, so that leads the values empty
public init?(_ addressString:String, type: AddressType = .normal, ignoreChecksum: Bool = false) { switch type { case .normal: guard let data = Data.fromHex(addressString) else {return nil} guard data.count == 20 else {return nil} if !addressString.hasHexPrefix() { return nil } if (!ignoreChecksum) { // check for checksum if data.toHexString() == addressString.stripHexPrefix() { self._address = data.toHexString().addHexPrefix() self.type = .normal return } else if data.toHexString().uppercased() == addressString.stripHexPrefix() { self._address = data.toHexString().addHexPrefix() self.type = .normal return } else { let checksummedAddress = EthereumAddress.toChecksumAddress(data.toHexString().addHexPrefix()) guard checksummedAddress == addressString else {return nil} self._address = data.toHexString().addHexPrefix() self.type = .normal return } } return nil case .contractDeployment: self._address = "0x" self.type = .contractDeployment } }

encoding name(ens) for sending register contract

Hi, @shamatar
there is a function in android web3 that encode name for ens like blew

public class NameHash {

    private static final byte[] EMPTY = new byte[32];

    public static byte[] nameHashAsBytes(String ensName) {
        return Numeric.hexStringToByteArray(nameHash(ensName));
    }

    public static String nameHash(String ensName) {
        String normalisedEnsName = normalise(ensName);
        return Numeric.toHexString(nameHash(normalisedEnsName.split("\\.")));
    }

    private static byte[] nameHash(String[] labels) {
        if (labels.length == 0 || labels[0].equals("")) {
            return EMPTY;
        } else {
            String[] tail;
            if (labels.length == 1) {
                tail = new String[] { };
            } else {
                tail = Arrays.copyOfRange(labels, 1, labels.length);
            }

            byte[] remainderHash = nameHash(tail);
            byte[] result = Arrays.copyOf(remainderHash, 64);

            byte[] labelHash = Hash.sha3(labels[0].getBytes(StandardCharsets.UTF_8));
            System.arraycopy(labelHash, 0, result, 32, labelHash.length);

            return Hash.sha3(result);
        }
    }

    /**
     * Normalise ENS name as per the
     * <a href="http://docs.ens.domains/en/latest/implementers.html#normalising-and-validating-names">specification</a>.
     *
     * @param ensName our user input ENS name
     * @return normalised ens name
     * @throws EnsResolutionException if the name cannot be normalised
     */
    static String normalise(String ensName) {
        try {
            return IDN.toASCII(ensName, IDN.USE_STD3_ASCII_RULES)
                    .toLowerCase();
        } catch (IllegalArgumentException e) {
            throw new EnsResolutionException("Invalid ENS name provided: " + ensName);
        }
    }
}

this class NameHash is used for hashing name (ens)
do we have any func like this in you're library?

thanks

Migration to web3 format (create account)

With web3js v1.0.0 you can create accounts with web3.eth.accounts.create(); and access the public address and private key with newWallet.address and newWallet.privateKey.

We have to implement the same thing in web3j (@ligi) and web3swift

Here an usage example:

newWallet = web3.eth.accounts.create() 
// access the public address 
newWallet.address
//private key:
newWallet.privateKey

Generating 12-word mnemonic from private key

Hey all, I would like to get a mnemonic representation of a private key. Right now, I am getting 24 words by doing the following:

    private func generateKey() -> String {
        let userDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
        var ks: EthereumKeystoreV3?
        ks = try! EthereumKeystoreV3(password: "PASSWORD")
        let keydata = try! JSONEncoder().encode(ks!.keystoreParams)
        FileManager.default.createFile(atPath: userDir + "/keystore"+"/key.json", contents: keydata, attributes: nil)
        var mnemonic: String = ""
        do {
            if let pk = try ks?.UNSAFE_getPrivateKeyData(password: "PASSWORD", account: (ks?.addresses?.first)!) {
                print("pk to hex: \(pk.toHexString())")
                let entropy = Data(hex: pk.toHexString())
                mnemonic = Mnemonic.create(entropy: entropy)
                print("pk hex to menmonic: \(mnemonic)")
            }
        } catch {print("Error with getting private key: \(error)")}
        return mnemonic
    }

I am using the Mnemonic helper class found here: https://github.com/essentiaone/HDWallet/blob/develop/HDWalletKit/Mnemonic/Mnemonic.swift

This is the Mnemonic.create function:

    public static func create(entropy: Data, language: WordList = .english) -> String {
        let entropybits = String(entropy.flatMap { ("00000000" + String($0, radix: 2)).suffix(8) })
        let hashBits = String(entropy.sha256().flatMap { ("00000000" + String($0, radix: 2)).suffix(8) })
        let checkSum = String(hashBits.prefix((entropy.count * 8) / 32))
        
        let words = language.words
        let concatenatedBits = entropybits + checkSum
        
        var mnemonic: [String] = []
        for index in 0..<(concatenatedBits.count / 11) {
            let startIndex = concatenatedBits.index(concatenatedBits.startIndex, offsetBy: index * 11)
            let endIndex = concatenatedBits.index(startIndex, offsetBy: 11)
            let wordIndex = Int(strtoul(String(concatenatedBits[startIndex..<endIndex]), nil, 2))
            mnemonic.append(String(words[wordIndex]))
        }
        
        return mnemonic.joined(separator: " ")
    }

A couple questions:

  • Would the user still be able to derive their private key from this mnemonic?
  • Also, instead of generating a 24-word mnemonic, is it possible to generate a 12-word mnemonic?

PromiseKit example

Could you please provide an example of how to use the async functions.
For example web3.eth.getGasPricePromise().then { ???? }

Whatever I do with what comes from autocomplete gives a build-time error.

Thanks!

How to get Keystore by PrivateKeyData ?

From @QA411 on September 3, 2018 8:46

How to get Keystore by PrivateKeyData ? Keystore eg:

{
  "address": "f13445645b52f597ca92e6f7c9987b16bc07ddb6",
  "crypto": {
    "cipher": "aes-128-ctr",
    "cipherparams": {
      "iv": "9ade19530af3e29106ed908bb46f3041"
    },
    "ciphertext": "d6236558690e5e9952ead703a4bc5bbe17a49cf47e8d8b4896fc46149c79586e",
    "kdf": "scrypt",
    "kdfparams": {
      "dklen": 32,
      "n": 4096,
      "p": 6,
      "r": 8,
      "salt": "127c2275de524cc6bd7ce21f804882d7aded732a77b5875026b56b97b1b1305a"
    },
    "mac": "288313bb2bb4ceccfa53f81e5c2803f45992222d3da74b94aa38e2a219088063"
  },
  "id": "e2092a8b-68bd-4801-bc3e-555e5dfc0878",
  "version": 3
}

Copied from original issue: BANKEX/web3swift#220

the version 1.1.6 couldn't from password and keystore to get the privateKey

1 month ago I downloaded the framework . It worked good. But these days I pod update, I find that the version 1.1.6 couldn't from password and keystore to get the privateKey and I don't know how to find the last version. I find the code is different in the file "CryptoExtensions.swift" from the old one.

Dear lovely writer, I am hearing from you!!!!

PS: I find the useful version 1.1.1 ,you can judge that use my func testPrivateKey, I promise that 1.1.6 need to solve the problem

func testPrivateKey() {
        let key = Data.init(base64Encoded: "eyJhZGRyZXNzIjoiMHgwYzI2OTgzZjUyODA2MWM0ZDQzYzY4MWE5ZTkxMzA0NTA2NjAwMWRiIiwiaWQiOiI1NGZkZWJjMi1iMjBjLTQ2YjktYmMzYy0zOTg1MWZiYzkzYjkiLCJ2ZXJzaW9uIjozLCJjcnlwdG8iOnsiY2lwaGVyIjoiYWVzLTEyOC1jdHIiLCJjaXBoZXJ0ZXh0IjoiOWU4OGE4YTI4MzA0ZmUyNTdkNjU1YjZjZWJlYjk4NmI2NmFhNWYwMTA0ZmYwYjBiMDQ2ZmQxMWUzNTJjNjg3MiIsImNpcGhlcnBhcmFtcyI6eyJpdiI6IjM5Nzk1Yzg2ZDc1NGE4ZTQzNTNiYjdlZTJkNmZkOWY2In0sImtkZiI6InNjcnlwdCIsImtkZnBhcmFtcyI6eyJka2xlbiI6MzIsIm4iOjQwOTYsInAiOjYsInIiOjgsInNhbHQiOiJkMjE0ZTU0MTczNjUwNmIzOTk2NTcwMjE5NzFkMzJiNjdhZDYxMGM5NTcwMWY0MWM5YTA0MTYxY2VlNTUwZjc2In0sIm1hYyI6ImViODlkMzAzMWNlODBiYjY1YTMyM2FlNzA4Y2E1NzYzZTU5MDM2NmRkMDM4Yzc4OTEyMWU2NTIxZjlmMzU2YzIifX0=")
        let password = "111111"
        let keystore = EthereumKeystoreV3.init(key!)
        let account = keystore!.addresses![0]
        let privateKey = try! keystore!.UNSAFE_getPrivateKeyData(password: password, account: account)
        let str = privateKey.toHexString()
        print(str)
    }

List of all transactions related to account (private key)

Is it possible to get the list of all past (historical) transactions quickly?
As I can see now - I can only get the count of transactions for account (using nonce number), but how can I get all these transactions in order to show to the user?

Carthage support

From @SteadyAction on July 31, 2018 3:42

please support Carthage..
I know it wont be easy because its dependencies do not support Cartharge :(
but any change?

Copied from original issue: BANKEX/web3swift#204

nodeError("replacement transaction underpriced")

i call a contract method twice in a short time,and create this error,i know this is beacuse of the same nonce,but i don't know how to solve it, i need call the method twice,make two transcation.Anyone can help?

calling a payable function with parameters

i'm struggling to find an example to use a payable function with parameters.

let's say i've an function in my Smart Contract:

    function doSomething(address[] _adresses, address[] _groups, uint[] _percentages)
        public
        payable
        returns(address) {

How do i call this SC and send ethers to it & pass parameters and get the return value?

Thanks.

ENS Functionality

Hey all, I am trying to build support for ENS into one of my mobile apps, (the ENS wallet from ETHBerlin), and I am having some trouble understanding how to get this done effectively.

I am attempting to interact with the Ropsten ENS contracts. Do I need to use the json ABI for the registrar in order to use it? Maybe it would be helpful to create a series of ENS handler classes like those found here: https://github.com/argentlabs/web3.swift/tree/master/web3swift/src/ENS

In the meantime, it would be super helpful if anyone could provide a guide or some examples on how to do this with the existing library functions. Thanks.

About deploying smart contracts

From @YanaWang0819 on September 27, 2018 12:15

Hello, I am running the deployment contract on my phone about the project times wrong,The content of error reporting is .failure(nodeError(desc: "base fee exceeds gas limit")),How to solve this problem? thank you!

Copied from original issue: BANKEX/web3swift#225

Installing issue by pod

Hi @shamatar
Im using this pod 'web3swift' for installing but I will get error while I'm building the project we didn't get error when we were using BANKEX/web3swift
look at this image:

Link Here

thanks

Recover passphrase from BIP32 store

Due to many requirements for such feature I should clarify:

  • Existing BIP32Keystore does NOT save the initial entropy (passphrase), it only stores latest element in key tree derivation path (please refer to BIP32 spec) to be able to produce user's keys. That means that you are SAFE TO USE the same seed phrase for Bitcoin, Litecoin, Ethereum, etc, and compromising the wallet will not give the hacker information about anything by your Ethereum wallet only!
  • I'll implement recoverable BIP32 keystore in the next release. Developers will be able to use it at their own risk!

Sincerely, Alex

new account

Can have an example of creating a new account?

ENS for wallets

Hi ,
Did you support ENS (Ethereum Name Service) in your SDK ?

Support objective-c

We need proxy methods for:

Web3 classes
ABIv2 classes
BlockExplorer classes
Contract classes
KeystoreManager classes
Transaction classes

calling a payable function with parameters

From @ungaro on August 23, 2018 10:59

i'm struggling to find an example to use a payable function with parameters.

let's say i've an function in my Smart Contract:

    function doSomething(address[] _adresses, address[] _groups, uint[] _percentages)
        public
        payable
        returns(address) {

How do i call this SC and send ethers to it & pass parameters and get the return value?

Thanks.

Copied from original issue: BANKEX/web3swift#214

Support Web3View functionality

Can you add feature to support delegate methods from WKWebView like web3view for TrustWallet on Android using your library:

Setters:
web3View.setChainID(chainID)
web3View.setChainType(chainType) // tesnet, mainet
web3View.setRpsUrl(url)
web3View.setWalletAddress(addressString)

Delegate methods:
web3View.setOnSignMessage(message) {
    print(message)
    web3View.signMessage()
}

web3View.setOnSignPersonalMessage(message) {
    print(message)
    web3View.signMessage()
}

web3View.setOnSignTransaction(transaction) {
    print(transaction)
    web3View.signMessage()
}

Send results:
web3View.signMessageCancel()
web3View.signMessageSuccessful(message, signedMessage)
web3View.signPersonalMessage(message, signedMessage)
web3View.signTransactionSuccessful(transaction, signedTx)

get transaction history failed

Here is my code

BlockExplorer().getTransactionsHistory(address: "0xd2b652df8987bddffc6b2068658efbd41ee5055f")
            .done { (records) in
                print(records)
            }
            .catch { (error) in
                print(error)
        }

It results in DecodingError.

▿ DecodingError
  ▿ keyNotFound : 2 elements
    - .0 : CodingKeys(stringValue: "rows", intValue: nil)
    ▿ .1 : Context
      - codingPath : 0 elements
      - debugDescription : "No value associated with key CodingKeys(stringValue: \"rows\", intValue: nil) (\"rows\")."
      - underlyingError : nil

BlockExplorer class gets records with https://scan.bankex.com/api/list API. Is it reliable?

How to signed Transaction

From @kirti301290 on October 6, 2018 11:12

hello
facing problem how to sign Transaction and get token then sent to server
pls help me

Copied from original issue: BANKEX/web3swift#230

how to decode input data from transaction

I have fetched transactions list from etherscan.io API. I need to decode input data to get the value and the token receiver address for ERC20Token transaction.

for example, the following input data

0xa9059cbb000000000000000000000000066a46470fd976e89303f501b704f73016da101e0000000000000000000000000000000000000000000000000de0b6b3a7640000

should be decoded as the picture showing
![Uploading [email protected]…](decoded input data)
How can I achieve this goal? A convenient function demo is expected.
Input Data url

How to signed Transaction ? get raw

web3.eth.signTransaction({
from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0",
gasPrice: "20000000000",
gas: "21000",
to: '0x3535353535353535353535353535353535353535',
value: "1000000000000000000",
data: ""
}).then(console.log);

{
raw: '0xf86c808504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a04f4c17305743700648bc4f6cd3038ec6f6af0df73e31757007b7f59df7bee88da07e1941b264348e80c78c4027afc65a87b0a5e43e86742b8ca0823584c6788fd0',
tx: {
nonce: '0x0',
gasPrice: '0x4a817c800',
gas: '0x5208',
to: '0x3535353535353535353535353535353535353535',
value: '0xde0b6b3a7640000',
input: '0x',
v: '0x25',
r: '0x4f4c17305743700648bc4f6cd3038ec6f6af0df73e31757007b7f59df7bee88d',
s: '0x7e1941b264348e80c78c4027afc65a87b0a5e43e86742b8ca0823584c6788fd0',
hash: '0xda3be87732110de6c1354c83770aae630ede9ac308d9f7b399ecfba23d923384'
}
}

how to custom nonce ?

create two transaction in a short time,will cause replacement error due to same nonce,so how to create
custom nonce transcation?Thank you!

Interface ideas are welcome for v2.0

Hello everyone.

I’d like to do a large interface overhaul in version 2.0 to make it more idiomatic. Public API for versions 0.X and 1.X is based on the JavaScript aimed interface of the reference web3 library.

Please feel free to use this issue as a discussion board for ideas and proposals.

Sincerely, Alex

Web3.Utils.formatToEthereumUnits

From @xiaoluSF on September 21, 2018 8:50

Hello !
I have a value 100 wei, format to Ethereum with fallbackToScientific is true.
result is '100e-16',but the correct is 1.0e-16.
Same, 1000wei or 10000 wei all have the wrong result.
This's the code,fullRemainder should format to x.xx..,but it is not processed here.
Another option is delete the break,make result is 100e-18
image

Copied from original issue: BANKEX/web3swift#224

web3swift.Web3Error error 4 for get balance

Hi @shamatar
I used the same exact code in one of my projects to get Balance and it works well but now I will get error with same situation, this is error code when I try to get balance:

The operation couldn’t be completed. (web3swift.Web3Error error 4.)
Link Here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.