Comments (3)
can you try following the instructions here https://github.com/QuarkChain/quarkchain-web3.js#web3qkccontract ?
from quarkchain-web3.js.
I wish that this example could help. @kvyb
// include the quarkchain-web3.js and web3.js in your head file
(function () {
web3 = new Web3();
//web3.setProvider(new web3.providers.HttpProvider());
web3.setProvider(new web3.providers.HttpProvider("http://jrpc.testnet.quarkchain.io:38391"));
QuarkChain.injectWeb3(web3, "http://jrpc.testnet.quarkchain.io:38391");
web3.qkc.setPrivateKey(YOUR_PRIVATE_KEY);
// for Chrome MetaMask Use and don't need private key
// if (typeof web3 === 'undefined') {
// const msg = "Couldn't detect web3. Make sure MetaMask is installed.";
// alert(msg);
// console.error(msg);
// return;
// }
// QuarkChain.injectWeb3(web3, "http://jrpc.testnet.quarkchain.io:38391");
})();
function deploy() {
var abi = YOUR_CONTRACT_ABI;
var bytecode = YOUR_CONTRACT_BYTECODE;
var contractClass = web3.qkc.contract(abi);
// for deploy, you need enough tqkc in your testnet account. Otherwise, you will get 0x00000000... txid in your console.
var contractInstance = contractClass.new(form.body.param1, form.body.param2, ...., form.body.paramN, {data: bytecode, gasPrice: 1000000000, gas: 1000000}, function(err, contract) {
if(!err) {
// NOTE: The callback will fire twice!
// Once the contract has the transactionId property set and once its deployed on an address.
// e.g. check tx hash on the first call (transaction send)
if(!contract.address) {
console.log(contract.transactionId); // The id of the transaction, which deploys the contract
var intervId = setInterval(function(){
var transactionReceipt = web3.qkc.getTransactionReceipt(contract.transactionId);
if(!transactionReceipt) {
console.log(Date.now());
}
else {
clearInterval(intervId);
console.log(transactionReceipt.contractAddress);
}
}, 2000);
// check address on the second call (contract deployed)
} else {
// i don't know why, it never get here in my try without metamask
console.log(contract.address); // the contract address
// Note that the returned "contractInstance" === "contract",
// so the returned "contractInstance" object will also get the address set.
}
} else {
}
});
}
from quarkchain-web3.js.
close for inactivity
from quarkchain-web3.js.
Related Issues (13)
- Can't interact with Contract in browser HOT 8
- guide to quarkchain-web3.js for the web HOT 2
- deploy contract with quarkchain-web3.js in browser without metamask HOT 3
- web3.qkc.getTransactionReceipt.contractAddress is a qkc address
- web3.qkc.getBalance() 和 sendTransaction() 两个函数无法调通 HOT 1
- Upgrade underlying web3js to latest
- SyntaxError: Unexpected identifier - While Running the node example of web3
- Add getTokenIdFromName HOT 1
- Add getBalances HOT 1
- Does contract.method.call() support all chainshards
- gas or gasLimit in rawTx
- Is QuarkChain.getQkcAddressFromEthAddress method not long avaliable?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quarkchain-web3.js.