我想在 RSK 和以太坊中构建一个每年支付股息的 Solidity 智能合约。假设 RSK 和以太坊当前的平均块间时间,我应该使用块时间还是可以依赖块编号?
在智能合约中,假设我有一个函数想要根据某些内部逻辑动态调用另一个函数。这里它获取函数选择器作为bytes4变量。
之后就可以使用分支逻辑来调用目标函数之一。看到)
但是,是否可以避免这种情况并直接调用函数选择器?参见:(B)
function myDynamicFunc(uint256 someParam) public {
bytes4 selector = /* ... some internal logic ... */
if (selector == this.myFuncA.selector) {
myFuncA(someParam);
} else if (selector == this.myFuncB.selector) {
myFuncB(someParam);
}
// (A) instead of something like this ^ branching logic (which works)
selector.invoke(someParam);
// (B) can something like this ^ instead by calling the selector directly instead (does not work)
}
Run Code Online (Sandbox Code Playgroud)
细节
myDynamicFunc是public和myFuncA+myFuncB也是public。我一直在调查一些用例的不同区块链.最后,我得出的结论是,设置私有区块链相当于拥有一个分布式数据库,其中包含不可变性,数字签名等区块链概念.例如:Bigchaindb.(好吧,如果我们确实需要智能合约功能,那么分布式数据库可能无效)
从理论上讲,哈希图一致性算法对于公共链来说看起来不够安全.它看起来像是Ripple的紧密替代版本.
综上所述,
在这里,我分享我的观点,了解私有链以何种方式优于分布式数据库?
我刚刚开始学习 Solidity,这是一项个人挑战。我不是开发人员,所以我还有很长的路要走。
我正在关注 Ethereum.org 教程,这是我有疑问的地方:“[msg.sender]”代表什么?我想这是触发合同的钱包地址,但我不确定。
提前,谢谢,祝你有美好的一天,苏马克
我有一个已经构建的Hyperledger Fabric系统,它可以处理x tps(每秒事务数).将来,对系统的要求可能不仅仅是x tps.
那么,如何扩展Hyperledger Fabric系统以满足更高的要求呢?
performance scalability blockchain hyperledger hyperledger-fabric
我正在学习混音的可靠性。我正在关注 youtube 上的一些教程视频,但在尝试建立 2 个合同时遇到了困难。合约 ERC20Token 具有增加余额的功能。并且 Mycontract 实例化并调用 mint 函数。我和 youtube 上的那个人一样,但我在调用 buyToken 函数时遇到了错误。错误是说
交易到 MyContract.buyToken 出错:VM 错误:恢复。
revert 事务已恢复到初始状态。
注意:如果您发送价值并且您发送的价值应小于您当前的余额,则应支付被调用的函数。调试事务以获取更多信息。
请帮帮我。
这是代码。
pragma solidity 0.5.1;
contract ERC20Token{
string public name;
mapping(address => uint256) public balances;
function mint() public {
balances[tx.origin] ++;
}
}
contract MyContract {
address payable wallet;
address public token;
constructor(address payable _wallet, address _token) public {
wallet = _wallet;
token = _token;
}
function buyToken() public payable {
ERC20Token _token = ERC20Token(address(token));
_token.mint();
wallet.transfer(msg.value);
} …Run Code Online (Sandbox Code Playgroud) 我正在从事一个以太坊项目,但我有一些疑问。我有一个通过 web3.js 连接到区块链的后端。为了连接到区块链,我使用 geth 节点。据我了解,顺序是这样的:
我正在尝试在 Nextjs 13.0.1 中像这样访问以太坊提供程序:
import { ethers } from "ethers";
export const signMessage = () => {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
try {
signer.signMessage("Hey hey").then((result) => {
console.log(result);
});
} catch (error) {
// handle error
console.log(error);
}
};
Run Code Online (Sandbox Code Playgroud)
但它总是给我错误:
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'Web3Provider')
Run Code Online (Sandbox Code Playgroud)
我尝试过不同的提供商,但总是收到上面的错误消息。
有人知道为什么它适用于 Nextjs 12 但不适用于 Next 13?
我正在尝试按照此过程https://docs.substrate.io/tutorials/build-a-blockchain/build-local-blockchain/#start-the-local-node启动本地节点。但它总是给我错误:
\n\xe2\x9e\x9c substrate-node-template git:(my-wip-branch) ./target/release/node-template --dev\n\n2023-04-07 12:59:26 Substrate Node \n2023-04-07 12:59:26 \xe2\x9c\x8c\xef\xb8\x8f version 4.0.0-dev-700c3a186e5 \n2023-04-07 12:59:26 \xe2\x9d\xa4\xef\xb8\x8f by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2023 \n2023-04-07 12:59:26 Chain specification: Development \n2023-04-07 12:59:26 Node name: extra-large-arch-5066 \n2023-04-07 12:59:26 Role: AUTHORITY \n2023-04-07 12:59:26 Database: RocksDb at /var/folders/dy/1hb072zd0g1d5ppckgm48ml40000gn/T/substrateekR4s0/chains/dev/db/full \n2023-04-07 12:59:26 \xe2\x9b\x93 Native runtime: node-template-100 (node-template-1.tx1.au1) \nError: Service(Client(VersionInvalid("cannot deserialize module: UnknownOpcode(192)")))\n2023-04-07 12:59:26 Cannot create a runtime error=Other("cannot deserialize module: UnknownOpcode(192)")\nRun Code Online (Sandbox Code Playgroud)\n我在另一个页面看到我必须没有最新版本的 rustup,所以我目前的版本已于 2023/01/01 更新:
\n\xe2\x9e\x9c substrate-node-template git:(my-wip-branch) rustup toolchain list\nstable-aarch64-apple-darwin\nnightly-2021-03-14-aarch64-apple-darwin\nnightly-2022-03-14-aarch64-apple-darwin\nnightly-2022-06-30-aarch64-apple-darwin\nnightly-2023-01-01-aarch64-apple-darwin (default)\nRun Code Online (Sandbox Code Playgroud)\n … blockchain ×10
ethereum ×7
solidity ×3
rsk ×2
bigchaindb ×1
docker ×1
ethers.js ×1
events ×1
evm ×1
hyperledger ×1
next.js ×1
performance ×1
remix ×1
ripple ×1
rust ×1
scalability ×1
substrate ×1
transactions ×1