Majd TL
  • Member for 3 years, 11 months
  • Last seen this week
  • Stuttgart, Deutschland
How to point web3j to other networks such as BSC?
Accepted answer
6 votes

If you are using the smart contact wrapper then you usually need to give one of the available transaction managers as a parameter and then give the chain Id when you initialize it Web3j web3 = Web3j....

View answer
how to get latest block number using web3j java APIs
6 votes

This is the easiest way Web3j web3j = Web3j.build(new HttpService("https://rinkeby.infura.io/v3/.......")); Block block = web3j.ethGetBlockByNumber(DefaultBlockParameterName.LATEST, false).send()....

View answer
Testing Error thrown with hardhat
Accepted answer
4 votes

When I test a function for revert I do the following in my javascript test file (e.g. myContractTest.js): const { expect } = require('chai'); const { ethers } = require('hardhat'); const { BigNumber } ...

View answer
How to replace Metamask Pop-Up with my own UI
Accepted answer
4 votes

I assume that you are connecting your DApp with the blockchain using the browser web3 instance, which is provided by metamask. The alternative is to use Infure or your own node and change the web3 ...

View answer
Offline transaction signing with web3j?
Accepted answer
3 votes

I think something like this should work // Create the Transaction RawTransaction rawTransaction = RawTransaction.createEtherTransaction(<nonce>, <gasPrice>, <gasLimit>, <...

View answer
Can a payable function be internal?
Accepted answer
3 votes

No internal and private function can't be declared as payable you will get a compiler error TypeError: "internal" and "private" functions cannot be payable The idea of having ...

View answer
Problems calling Smart Contract function in Java using Web3j
Accepted answer
3 votes

modify your build.gradle to this and rebuild (i usually use maven), the problem was probably with okhttp used in web3j dependencies { // https://mvnrepository.com/artifact/org.web3j/core ...

View answer
Function warning for 'view' and code 'not reacheable'
Accepted answer
2 votes

It is unreachable code it is not a warning it is a bug in your code? you are only checking the first element in the registered array and return directly false or true without looking at the rest of ...

View answer
What is this function do internally of Time Lock Controller of Solidity?
2 votes

I found this information in the doc of OpenZeppelin for v.4.x here First, what is an operation? it is a transaction (or a set of transactions) that is the subject of the timelock. It has to be ...

View answer
Testing arguments of contract events with hardhat + chai
Accepted answer
2 votes

This is how I do that for the Transfer event of the ERC20 tokens: usually : await expect(tokenInstance.connect(<signer-account>).transfer(<addr-of-receipent>, <amount-BigNumber>)) ....

View answer
Get mapping value in hardhat
Accepted answer
2 votes

I think it should be public. Therefore add the public modifier before the variable mapping (uint256 => uint256) public totalBoostedPercent;

View answer
Error when deploying contract to Mainnet but not Testnet
2 votes

Probably it is the mistake, but I'm not sure: You have sent extra 60 wei with your contract. that(see the picture) is no the transaction fee and it should always be 0 unless your contract expecting ...

View answer
How do I overcome the problem of gas limit?
Accepted answer
2 votes

networks { development: { host: "127.0.0.1", // Localhost (default: none) port: 8545, // Standard Ethereum port (default: none) network_id: "*", // Any ...

View answer
The method eth_sendTransaction does not exist/is not available on infura
Accepted answer
2 votes

dude (this is the third question about the same thing), I have changed some methods if you have questions about it write it down please and dont open a new question :) this is the new code var Tx = ...

View answer
How do I deposit Ether to Smart Contract using Web3.js
Accepted answer
2 votes

function depositFunction() { contractInstance.deposit({ from: web3.eth.accounts[0], value: <amount-in-Wei>}, function(err, result){ .... } ); }

View answer
How to compare an address with an address using web3js?
Accepted answer
2 votes

Maybe you should use tolowercase() on both addresses, and better to console.log them first and see if one of them has 0x or if they already equal

View answer
Not accessing metamask address through web3.eth.getCoinbase
Accepted answer
2 votes

In Metamask, go to Setting -> Privacy & Security -> deactive the "Privacy Mode" option. If you want to use the Privacy Mode then you have to modify your code https://medium.com/metamask/eip-...

View answer
web3j.ethSendRawTransaction wait until the transaction is successfully mined - Web3j
Accepted answer
2 votes

That worked for me: while (true) { EthGetTransactionReceipt transactionReceipt = web3j .ethGetTransactionReceipt(transactionHash) .send(); if (transactionReceipt.getResult() ...

View answer
send data & ether to other contract in the same method
Accepted answer
2 votes

i found the answer c.register.value(msg.value)(_i);

View answer
How to run hardhat tests on a testnet?
Accepted answer
1 votes

Make sure your accounts have balances. And you can config the timeout depends on each network by adding a timeout property in milliseconds (https://hardhat.org/config/#json-rpc-based-networks) example:...

View answer
Member "slice" not found or not visible after argument-dependent lookup in struct Ballot.Proposal storage ref[ ] storage ref
1 votes

According to the documentation here As of now, array slices are only implemented for calldata arrays. Your proposals array is stored in the storage and it is not calldata. check these for more ...

View answer
My remix.eth page does not connect with my metamask account
1 votes

First, try to disconnect your metamask from everything by clicking on that green "Connected" on the left side from metamask and then disconnect all accounts. After that lockout from Metamask ...

View answer
Difference between smart contract and wallet address
Accepted answer
1 votes

A smart contract address is an ethereum address that has code/data behind it. so to check if the given address is "currently" a contract you can use the getCode method from Web3js web3.eth....

View answer
Is there a way to detect if a token was already approved?
1 votes

You can use the allowance method to check if the spender is approved to transfer tokens on behalf of the owner. the method will return you the approved amount to spend https://docs.openzeppelin.com/...

View answer
how to convert "0.5" number knowing decimals to a valid bignumber
1 votes

That is usually how I calculate half of a token. but I don't guarantee that it works correctly :) so please check the code and make sure it works and is correct and use it only on your own ...

View answer
how to store the gasprice as integer rather than object?
Accepted answer
1 votes

As KonyTech sais "web3.eth.getGasPrice() returns a Promise so you must treat it as such. In your example a is the Promise, not the gas price" (so you need to understand what are promises in ...

View answer
First Smart Contract: How to emit exact string data?
1 votes

I think those are: memory or data slot starts at byte 20 data length in your case 12 bytes then what is inside the memory/data bytes="48 65 6c 6c 6f 20 77 6f 72 6c 64 21" which is your &...

View answer
How can i read symbol and name of the token in transaction?
1 votes

In the Transaction Input there is usally(ERC20) nothing about the name or symbol of the Token, however you can get the address of smartcontract from the Transaction (not Input), and then you can get ...

View answer
How can I do an internal transfer using OpenZeppelin code?
Accepted answer
1 votes

I think you need to call your contract by your contract so try "this.transfer"... simplified -> the keyword "this" will call the transfer function as an external function and ...

View answer
Are these two equal: web3.eth.getCode(<contract-address>) === type(Contract).creationCode
Accepted answer
1 votes

No, the getCode method gives back the runtime code which is stored on the Blockchain. you can see that in this article: Runtime Bytecode: This is the code that is stored on-chain that describes a ...

View answer