The Solidity Contract-Oriented Programming Language - By chatting here you agree to the https://github.com/ethereum/solidity/blob/develop/CODE_OF_CONDUCT.md
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Test1{
uint private a1 = 11;
function get() public view returns (uint){
return a1;
}
function set(uint a) public{
a1=a;
}
function set1() public {
a1=22;
}
fallback() external {
a1=33;
}
}
contract Test2{
function call_1(address contractAddress) public{
(bool success,bytes memory a) =contractAddress.call(abi.encodeWithSignature("set(uint)",44));
require(success);
}
function call_2(address contractAddr) public {
(bool success,) = contractAddr.call(abi.encodeWithSignature("set1()")); require(success);
require(success);
}
}
function "call_1" does not work
const DOMAIN_TYPE = [
{
type: 'string',
name: 'name'
},
{
type: 'string',
name: 'version'
},
{
type: 'uint256',
name: 'chainId'
},
{
type: 'address',
name: 'verifyingContract'
}
];
const domainData = {
name: 'Market721',
version: '1',
chainId: '1337',
verifyingContract: '0x296564F6260b95f99F93fB347d456b7FC825771b'
};
const OrderTypes = {
AssetType: [
{ name: 'assetClass', type: 'bytes4' },
{ name: 'data', type: 'bytes' }
],
Asset: [
{ name: 'assetType', type: 'AssetType' },
{ name: 'value', type: 'uint256' }
],
Order: [
{ name: 'maker', type: 'address' },
{ name: 'makeAsset', type: 'Asset' },
{ name: 'taker', type: 'address' },
{ name: 'takeAsset', type: 'Asset' }
]
};
const createTypeData = (domain, primaryType, message, types) => {
return {
types: { EIP712Domain: DOMAIN_TYPE, ...types },
domain,
primaryType,
message
};
};
const leftUH = {
maker: "0xfa6954192c3087f9143f5401f7804b405ac84ca5",
makeAsset: {
assetType: {
assetClass: id('ERC20'),
data: web3.eth.abi.encodeParameter('address', '0xfa6954192c3087f9143f5401f7804b405ac84ca5')
},
value: BigNumber("100000000")
},
taker: "0x3bed4334ce380cfe41363c7e875a9fc1769578b1",
takeAsset: {
assetType: {
assetClass: id('ERC721'),
data: web3.eth.abi.encodeParameter({ root: { contract: "address", tokenId: "uint256" }}, { contract: '0xfa6954192c3087f9143f5401f7804b405ac84ca5', tokenId: 1 })
},
value: "1"
}
};
const leftMsgParams = createTypeData(domainData, 'Order', leftUH, OrderTypes)
const leftSig = sigUtil.signTypedData_v4(Buffer.from(leftAcc, 'hex'), { data: leftMsgParams });
Hi I'm actually doing an online course and I'm developping on nextjs but I have this poblem on my web3.js code :Server Error
ReferenceError: window is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
eth/web3.js (3:0) @ eval
1 | import Web3 from "web3";
2 |
3 | window.ethereum.request({ method: "eth_requestAccounts" });
4 |
5 | const web3 = new Web3(window.ethereum);
6 |
Hi @cameel:matrix.org I read in the docs:
block.basefee (uint): current block’s base fee (EIP-3198 and EIP-1559)
https://docs.soliditylang.org/en/v0.8.9/cheatsheet.html?highlight=block.basefee
It's a bit ambiguous as to whether this is the base fee of the previous block or the current block that this transaction will be included in.
Is it the basefee of the block that the transaction is included in?
Also I wondered what's the best way to get the value for the transactions priorityFee?
Is it: tx.gasprice - block.basefee
?
web3.js
within a browser or server context?