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 can we deploy smart contract using webe3swift? #612

Closed
ShoaibKakal opened this issue Aug 31, 2022 · 1 comment
Closed

How can we deploy smart contract using webe3swift? #612

ShoaibKakal opened this issue Aug 31, 2022 · 1 comment
Labels
FAQ common questions tend to recur about web3 infra

Comments

@ShoaibKakal
Copy link

In web3java, i can deploy a smart contract by following the methods

  • Create .bin and .abi files from solidity file using solcjs library.
  • Create java file using .abi and .bin files.
  • Java file contains deploy() method to deploy a smart contract on Ethereum network.

Now in web3swift i don't see any method to deploy smart contract. I know there will be any other way of deploying but i don't know. can anyone please help in this regard?

@JeneaVranceanu
Copy link
Collaborator

Hello.
You can try using one of the following options.
There is definitely an improvement for that API coming but I cannot tell when exactly that will be done.

Options:

  1. Create the whole transaction
// Some smart contract instance
let contract = web3Instance.contract(...)

// A transaction ready to be signed and executed
let writeTransaction = contract.prepareDeploy(bytecode: yourScBytecode)
...
  1. Create only encoded data - how a transaction object will be created is up to you.
// It throws only if you give two functions with exactly the same name and input but different output.
// That's an invalid overloading of a function. We're safe here thus using `try!`.
let contract = try! EthereumContract(abi: [])

// There is also an option to pass constructor and input arguments
let encodedData = contract.deploy(smartContractBytecode)
...

@Kristenlike1234 Kristenlike1234 added the FAQ common questions tend to recur about web3 infra label Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FAQ common questions tend to recur about web3 infra
Projects
None yet
Development

No branches or pull requests

3 participants