Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to signed Transaction #61

Closed
skywinder opened this issue Oct 6, 2018 · 6 comments
Closed

How to signed Transaction #61

skywinder opened this issue Oct 6, 2018 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@skywinder
Copy link
Collaborator

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

@skywinder skywinder added the question Further information is requested label Oct 7, 2018
@QA411
Copy link

QA411 commented Oct 8, 2018

hello, EthereumTransaction.init(gasPrice: 1, gasLimit: 1, to: address!, value: 1, data:NSData) What is it data ? you have Examples?

@kirti301290
Copy link

Hello any solution
pls help me

@QA411
Copy link

QA411 commented Oct 15, 2018

// transactionSign
func transactionSign(nonce :String,gasPrice :String,gasLimit :String,toAddress :String,value :String,privateKeyData :Data,chainID :String,templateData :Data) -> Data {

    var transaction = EthereumTransaction(nonce: BigUInt(nonce)!,
                                          gasPrice: BigUInt(gasPrice)!,
                                          gasLimit: BigUInt(gasLimit)!,
                                          to: EthereumAddress(toAddress)!,
                                          value: BigUInt(value)!,
                                          data: templateData,
                                          v: BigUInt(0),
                                          r: BigUInt(0),
                                          s: BigUInt(0))
    transaction.UNSAFE_setChainID(BigUInt(chainID)!)
    print(transaction)
    try! Web3Signer.EIP155Signer.sign(transaction: &transaction, privateKey: privateKeyData, useExtraEntropy: false)
    print(transaction)
    let encoded:Data? = transaction.encode()
    return encoded!
}

@kirti301290
Copy link

@QA411 thank for quick reply
i think you made some custom function
my provider is Rinkeby
what to pass in parameter
chainid - ?
templateData - ?
privateKeyData - ?
thanks

@QA411
Copy link

QA411 commented Oct 15, 2018

templateData is token user. ETH is nil.
privateKeyData is privateKey

chainid :
public var chainID: BigUInt {
switch self {
case .Custom(let networkID): return networkID
case .Mainnet: return BigUInt(1)
case .Ropsten: return BigUInt(3)
case .Rinkeby: return BigUInt(4)
case .Kovan: return BigUInt(42)
}
}

@BaldyAsh
Copy link
Collaborator

I think its done. Closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants