Comments (3)
I tried out the code (there is a typo which I fixed) in my browser and it seems to work fine:
no need to set up server or html, just go to http://testnet.quarkchain.io/ (NOTE https won't work) and paste the js code, all works fine and the contract was created successfully http://testnet.quarkchain.io/tx/0xeb7c3f469a424a9e003466f8ba212314b8fdaa5fd2eda362fc39902f85e2203b00872619
I can see the POST http://jrpc.testnet.quarkchain.io:38391/ 404 (Not Found)
error as well, but if you go to network tab and see what it is about, the method is eth_newBlockFilter
, I don't think it really matters, we can just kill it later
from quarkchain-web3.js.
Thanks so much for your reply.
I'm sorry for the typo made when I write the issue...However, I can deploy the contract but I still can't get the contract address for the second callback never happened.
I change the workflow. Use the func getTransactionRceipt
with setInterval
to get the contractAddress in first callback func. It can work now.
code as follows:
var tokenContractReturned = TokenContract.new(parseInt(req.body.totalSupply), req.body.tokenName, req.body.symbol, parseInt(req.body.decimals), req.body.ownerAddress, parseInt(req.body.buyRate), Date.parse(req.body.endDate),
{
data: bytecode,
gasPrice: 1000000000,
gas: 1000000,
fromFullShardId: finalFullShardId,
},function(err, tokenContract){
if(!err) {
//fromFullShardId: getTargetFullShardId(req.app.get('shard'))},
// 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(!tokenContract.address) {
console.log("/////////////////////txid////////////////////");
console.log(tokenContract.transactionId); // The id of the transaction, which deploys the contract
var transactionId = tokenContract.transactionId;
var transactionReceipt;
var intervId = setInterval(function(){
transactionReceipt = web3.qkc.getTransactionReceipt(transactionId);
if(!transactionReceipt) {
console.log(Date.now());
}
else {
clearInterval(intervId);
console.log(transactionReceipt);
req.app.set('shard', (req.app.get('shard')+1)%32);
res.json({address: `${transactionReceipt.contractAddress}${finalFullShardId.slice(2)}`});
}
}, 2000);
// check address on the second call (contract deployed)
} else {
console.log("/////////////////////address/////////////////");
console.log(tokenContract.address); // the contract address
}
// Note that the returned "myContractReturned" === "myContract",
// so the returned "myContractReturned" object will also get the address set.
}
});
from quarkchain-web3.js.
oh, the fact that using a interval works probably means the server won't have the contract address ready until some time has passed :-)
from quarkchain-web3.js.
Related Issues (13)
- 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?
- Can't interact with Contract in browser HOT 8
- guide to quarkchain-web3.js for the web HOT 2
- Create smart contract with quarkchain web3 HOT 3
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.