2

Both web3js and web3php are just libraries to communicate with the Ethereum blockchain. You can ask through a browser (then you'd use web3js), or from a server (then you'd use web3php), some information (like, what's the balance of this address, or call some contract's method to read something).


2

how do we register user in smart contract You're struggling to find this description because the task is already done for you, depending on what you mean by the process of "registering". get the userdata when he/she tries to login after register through our website This is full of hidden assumptions and ambiguities. who/what gets the userdata? ...


2

To receive ERC20 payments you usually use the combination of user's approval and transferFrom from the contract. User calls token's approve function with the recipient contract address. Using a wallet, perhaps Metamask. In javascript it will look like: token.approve(recipientContactAddress, amount, { from: userAddress }); User calls a function from the ...


1

You have at least two options: Write your own interface which inherits from the IA and adds the missing functionality. This is by far the nicest approach Use something like call or delegateCall to call functionality in another contract without direct reference to the function. So basically you craft the call to the other function by hand. You can find more ...


1

This: const Web3 = require("web3"); console.log(Web3.utils.asciiToHex("foo")); console.log(Web3.utils.asciiToHex("bar")); Gives: 0x666f6f 0x626172 So I believe that one of the following should work for you: [0x666f6f, 0x626172] ["0x666f6f", "0x626172"] [...


1

There are two kinds of functions. One, the functions called "Getter" and the other the functions called "Setter". Getter functions do not change the state and used to get some data from smart contract. For this reason, they are always called with this command in Truffle console: getterFunctionName.call() Setter functions change the ...


1

Try this: pragma solidity ^0.5.0; contract A { function a() public returns(uint256) { return 2; } } contract B { address addrOfA; constructor (address _addrOfA) public { addrOfA = _addrOfA; } function b() public returns(uint256) { (bool success, bytes memory result) = address(addrOfA).delegatecall(abi....


1

The question is pure javascript one and has nothing to do with Ethereum, but I will give you the answer, because you're a new contributor and I hope next time you will pay more attention to keep this forum only Ethereum related. var arr = [0, 0, 1602907512, 1602907764, 1602907512, 1602907764, 60000000, 90000000]; var outcomeArr = []; var tempCounter = 0; ...


1

In JavaScript, We suppose you defined your contract object in a variable called `MyContract'. By the below statement, in an async function, you can get array result: let MyContractOutput= await MyContract.methods.getPlayerDeposit(<Give an address>).call(); By this way, you get the result like this: 0,1602907512,1602907512,60000000 In order that you ...


1

I assume you want to convert the BigNumber into a normal number, you can do that by: result[0].toNumber() But keep in mind that JavaScript's Number is a 64 bit number, so the uint256 in your solidity contract might not always be shrinked down to 64 bits. A safer way to to that is to keep the number in String, if you don't want to do any additions or ...


1

That is a poorly worded comment. It should read: Create a table so that we can map the addresses of token owners to those who are allowed to utilize the said owner's tokens. This lets you whitelist someone else to use your tokens. For instance, you can allow me to spend 10 of your tokens. So, with .approve, you save in the mapping: you => me => 10 ...


1

I'm not sure where you found that example but there are multiple issues with it: It's old. That version of Solidity shouldn't be used in new projects anymore The comments in it do not make sense so just ignore them It has a bit of weird code Perhaps the best and most widely-used modern implementation is from OpenZeppelin at https://github.com/...


1

Subhod's answer above is good, but for variety's sake, here's a version I wrote that avoids ints entirely and keeps everything uints. I've kicked the tires a bit but you should test further before deploying it. Also of course, as Nick Johnson noted on Twitter, quicksort's worst case is slow (O(n^2)) so you might want to find a faster O(n log n) one. ...


Only top voted, non community-wiki answers of a minimum length are eligible