Coder Social home page Coder Social logo

mercuryprotocol / web3.swift Goto Github PK

View Code? Open in Web Editor NEW
112.0 13.0 20.0 23.61 MB

Web3 and Geth wrapper utility in swift

Home Page: https://www.mercuryprotocol.com/

License: MIT License

Ruby 6.41% Swift 91.64% Objective-C 1.95%
swift4 geth web3 crypto mercuryprotocol

web3.swift's Introduction

CocoaPods Compatible Platform Latest Tag Twitter

web3.js utility library written in Swift.

Table of contents

Features

  • Create Account
  • Import Account
  • Create and Encode Transaction
  • Sign Transaction
  • More Features - WIP
  • Complete Documentation

Component Libraries

In order to keep web3swift focused specifically on core ethereum based utility functionality, additional component libraries will be created by the Radical App LLC to bring additional functionality to the mercury protocol ecosystem.

  • iOS Example App - Example showcasing use of web3swift library.
  • [Mercury Wallet - Wallet App to use with mercury protocol. (Coming Soon)

Requirements

  • iOS 9.0+
  • Xcode 9.2+
  • Swift 4.0.0+

Communication

  • If you need help, use Stack Overflow. (Tag 'web3swift')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

CocoaPods

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

$ sudo gem install cocoapods

CocoaPods 1.1+ is required to build web3swift 4.0+.

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

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

target '<Your Target Name>' do
    use_frameworks!
    pod 'web3swift', :git => 'https://github.com/MercuryProtocol/web3.swift.git', :branch => 'master'
end

Then, run the following command:

$ pod install

Sidenote:

  • In order to run project, you will have to turn off bitcode support as Geth doesn't support bitcode. Please check: golang/go#22395
  • iOS simulator compilation can be fixed by removing arm7 support from valid architectures in the app. You can find more information here.

USAGE

Create Account

Create keystore and account with password.

let configuration = EthAccountConfiguration(namespace: "wallet", password: "qwerty")
let (keystore, _) = EthAccountCoordinator.default.launch(configuration)

If you don't want to create account, this can be achieved by passing nil

let configuration = EthAccountConfiguration(namespace: "wallet", password: nil)
let (keystore, _) = EthAccountCoordinator.default.launch(configuration)

Encoding Transaction

var addressError: NSError? = nil
let amountToTransfer = 5
let gethToAccountAddress: GethAddress! = GethNewAddressFromHex("0x39db95b4f60bd75846c46df165d9e854b3cf2b56", &addressError)
guard let amount = GethBigInt.bigInt(amountToTransfer) else {
    print("Invalid amount")
    return
}
let transferFunction = EthFunction(name: "transfer", inputParameters: [toAccountAddress, amount])
let encodedTransferFunction = web3swift.encode(transferFunction)

Signing Transaction

let signedTransaction = web3swift.sign(address: contractAddress, encodedFunctionData: encodedTransferFunction, nonce: nonce, gasLimit: Constants.gasLimit, gasPrice: Constants.gasPrice)

FAQ

What's web3swift?

web3swift is utility library written in swift which brings web3j encoding capabilities to Swift. Also, helps managements of account based on Geth.

Credits

web3swift is owned and maintained by the Radical App LLC. You can follow them on Twitter at @MercuryProtocol for project updates and releases.

Contributors

If you do want to participate please follow the guideline.

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 released under the MIT license. See LICENSE for details.

web3.swift's People

Contributors

roviko avatar skhavanekar 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

web3.swift's Issues

Syntax Errors...!!!

I have successfully installed web3 using cocoapods and it has installed.when i build the project its giving alot of errors in CryptoSwift.
Need Help...
screen shot 2018-04-11 at 4 20 32 pm

Not Working on rinkeby provider

Hello
i did sign transction then get token then sending that token to my server
it showing success but amount not deducted from account

let me know your library support rinkeby provider ?
pls help me

Set provider url

Hi, where to set my provider like we do on web3
var web3 = new Web3(new Web3.providers.HttpProvider(provider));
PS: I didn't find another place to request information sorry for opening the "issue"

How to extract the public key and private key from GethKeyStore?

Hi, thanks for the library!

  1. I seem to be stumbling trying to find this function, how do you extract the public and public keys from the GethKeyStore, or can you get those from the GethAccount?
  2. Can you recreate a GethAccount using only the privateKey?
  3. about this function public func sign(message: Data) -> SignatureData? {}, how do i get the MessageSignatureHash that you can pass e.g. https://etherscan.io/verifySig to verify the signature?

[Build Failure] Int64 conversion to GethBigInt

Issue:

Unable to build pod due to the below error.

Error: Cannot convert value of type 'Int64' to expected argument type 'GethBigInt!' at buildtime
Installation: CocoaPods v1.5.0
Version: web3swift (0.0.9)
Dependency Versions: CryptoSwift (0.8.1), Geth (1.7.3)

Repro Steps:

  1. Create empty project
  2. Install web3 via CocoaPods
  3. Build (failed)

Screenshot(s)

screenshot

Signing and unsigning.

I was doing some experimentation in developing an application that used the public ethereum blockchain, and accessing with web3.js. I poked around in this repository, looking for some specific web3.js functions, like "sign" and "ecrecover", but I didn't see them. I do see a "sign" method associated with transactions, however. I want to be able to sign a user generated string/data, and then later recover the signer from a signature. I was using web3.eth.personal.sign and web3.eth.personal.ecRecover. Are similar functions available in this package? Thanks.

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.