我正在做一个主题为“销售”的项目。所以,对于前端(React)和后端(PHP)。
我在理解如何在项目中使用我的智能合约时遇到了问题。为了部署,我使用以太坊钱包 0.9.0 和测试网络 Rinkeby。他在 EW 工作。
假设我的代码中有购买按钮,并且我的合约中有如下功能:
function Buy()
public
payable
{
require (msg.sender != seller);
require (msg.value >= price);
orderNum++;
safePay +=msg.value;
}
Run Code Online (Sandbox Code Playgroud)
现在,我该如何使用它?我听说过 web3.js,但是(我不确定)我需要 php 请求。
或者,如果我的合约部署在以太坊钱包 Rinkeby 中,我可以直接通过代码使用它,不需要再次部署。
我是这个主题的初学者,可能会犯错误(即使在视图中),但如果有人可以解释这一点,我会非常高兴。
谢谢。
我知道超级账本网络中的每个实体都需要一个身份。此身份由证书颁发机构提供。本地和频道 MSP 将此身份与组织映射,并为该身份赋予角色。
几个问题:
目前我尝试自己验证比特币区块77504。但从中本聪的白皮书来看,我似乎有更多的问题而不是答案。
来自前一个块的第一个信息:
### What we know from last block ###
# height = 77503
# id = 00000000000447829abff59b3208a08ff28b3eb184b1298929abe6dd65c3578a
# version = 1
# timestamp = 1283325019
# bits = 459874456
# nonce = 1839166754
# difficulty = 623.3869598689275
# merkle_root = f18107935e8853011e477244241b5d786966495f8c59be46c92ac323c9cc8cde
# tx_count = 6
# size = 1438
# weight = 5752
Run Code Online (Sandbox Code Playgroud)
然后是我想要验证的区块的信息
### What we now want to mine ###
# height = 77504
# id = 00000000004582246e63ff7e0760c6f009e5ef5ce1eb5397be6f3eb9d698bda5
# version = 1
# timestamp = 1283326637
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个 5 节点网络(所有验证者以及 Aura 和 GRANPA 的成员),我的目标是使用自定义密钥,而不是预定义的 Alice 等。因此在自定义规范 JSON 中添加了 SR 和 ED 授权密钥文件。节点模板版本是来自 Github 的未更改的 V3。
\n我按照教程(https://substrate.dev/docs/en/tutorials/start-a-private-network/customchain)进行操作,但出现此错误:
\n\n2021-07-26 09:17:35 Substrate Node\n2021-07-26 09:17:35 \xe2\x9c\x8c\xef\xb8\x8f version 3.0.0-unknown-x86_64-linux-gnu\n2021-07-26 09:17:35 \xe2\x9d\xa4\xef\xb8\x8f by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021\n2021-07-26 09:17:35 Chain specification: The Batman Chain\n2021-07-26 09:17:35 Node name: Node1\n2021-07-26 09:17:35 Role: AUTHORITY\n2021-07-26 09:17:35 Database: RocksDb at /peer-data-1/chains/TBC_testnet/db\n2021-07-26 09:17:35 \xe2\x9b\x93 Native runtime: node-template-100 (node-template-1.tx1.au1)\n2021-07-26 09:17:36 Initializing Genesis block/state (state: 0x531c\xe2\x80\xa6653b, header-hash: 0x4c1f\xe2\x80\xa6570d)\n2021-07-26 09:17:36 Loading GRANDPA authority set from genesis on …Run Code Online (Sandbox Code Playgroud) 我的托盘中运行着一个链下工作实例,它在时代选举结束后调用一个未签名的外部实例。这个未签名的外部数据的目的是在链下索引存储中存储一些数据,供下一个时代的所有验证者使用。如果有超过 1 个验证器在同一块中调用此无符号外部,我会收到以下错误:
2021-10-06 14:06:19.406 WARN ThreadId(26) txpool: (offchain call) Error submitting a transaction to the pool: Pool(TooLowPriority { old: 10100, new: 10100 })
2021-10-06 14:06:19.406 ERROR ThreadId(26) pallet_participant: Failed in submit_participant
2021-10-06 14:06:19.406 ERROR ThreadId(26) pallet_participant: offchain_worker error: OffchainUnsignedTxSignedPayloadError
Run Code Online (Sandbox Code Playgroud)
经过一番挖掘(此处),我发现错误是由于同一块中的两个无符号外部变量具有相同的随机数而导致的。就我而言,由于我的托盘正在开发中,因此我的外部重量设置如下:
#[weight = 10000]
pub fn submit_participant(_signature: T::Signature) -> DispatchResult {
Run Code Online (Sandbox Code Playgroud)
我的验证未签名函数的事务优先级设置如下:
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
let valid_tx = |provide| {
ValidTransaction::with_tag_prefix("pallet-participant")
.priority(100)
.and_provides([&provide])
.longevity(3)
.propagate(true)
.build()
};
Run Code Online (Sandbox Code Playgroud)
所以问题是如何管理随机数,以便它不会给我带来有关事务优先级的错误?如果有一个此类实现的示例,那将非常有帮助。
我是区块链技术的新手。我正在尝试部署智能合约。但我在编译 sol 文件时总是遇到以下错误。它正在工作,但突然停止工作。我没有做任何改变。
这是我收到的错误
Traceback (most recent call last):
File ".\main.py", line 68, in <module>
main()
File ".\main.py", line 57, in main
compiled_sol = compile_source_file('contract.sol')
File ".\main.py", line 20, in compile_source_file
return solcx.compile_source(source)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\solcx\main.py", line 130, in compile_source
allow_empty=allow_empty,
File "C:\Program Files (x86)\Python37-32\lib\site-packages\solcx\main.py", line 277, in _compile_combined_json
combined_json = _get_combined_json_outputs(solc_binary)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\solcx\main.py", line 242, in _get_combined_json_outputs
help_str = wrapper.solc_wrapper(solc_binary=solc_binary, help=True)[0].split("\n")
File "C:\Program Files (x86)\Python37-32\lib\site-packages\solcx\wrapper.py", line 163, in solc_wrapper
stderr_data=stderrdata,
solcx.exceptions.SolcError: An error occurred during execution …Run Code Online (Sandbox Code Playgroud) 运行时,solana-test-validator它会开始一个新进程,并输出以下内容:
Ledger location: test-ledger\nLog: test-ledger/validator.log\nIdentity: 4876NsAf6yH8c7uPXybETZPit142i2QhR7tfSoTPYjHf\nGenesis Hash: CrqeHuGVmgHL54Sri7dEm2aCRLFopJrTHoQBYe6ciF7N\nVersion: 1.8.17\nShred Version: 28931\nGossip Address: 127.0.0.1:1024\nTPU Address: 127.0.0.1:1027\nJSON RPC URL: http://127.0.0.1:8899\n\xe2\xa0\x84 01:44:22 | Processed Slot: 48335 | Confirmed Slot: 48335 | Finalized Slot: 483\nRun Code Online (Sandbox Code Playgroud)\n我明白:
\n我还阅读了 Solana 集群、验证器、插槽、纪元文档。\n它说
\nSlot: The period of time for which each leader ingests transactions and produces a block.\nRun Code Online (Sandbox Code Playgroud)\n有人能解释一下当我们跑步时会发生什么吗solana-test-validator?特别是,它会产生区块/分类帐条目吗?从它不断显示的内容来看\n \xe2\xa0\x84 01:44:22 | Processed Slot: 48335 | Confirmed Slot: 48335 | …
我正在尝试将代币 [USDT] 从一个钱包发送到另一个钱包。但我认为我在理解关联令牌帐户 [ATA] 的概念时遇到了一些困难
据我的理解:
1 - 每个想要保存、接收或发送代币的钱包账户都必须在网络中的账户中注册这些代币吗?
2 - 发送方可以注册接收方的帐户
3-这些概念正确吗?
以上所有操作均通过以下指令完成=>
AssociatedTokenAccountProgram.CreateAssociatedTokenAccount
4 - 一旦接收者的钱包地址被注册,就可以通过指令将代币发送给他=>
TokenProgram.Transfer
Account ownerAccount = wallet.Account;
PublicKey UsdtAddress = new PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
PublicKey ToAddress = new PublicKey("CDQ3Gya9QermsPzU3cTNW9QPLbMVLbALQ2S8AwbruVJ");
var Transaction = new TransactionBuilder().
SetRecentBlockHash(blockHash.Result.Value.Blockhash).
SetFeePayer(wallet.Account).
AddInstruction(AssociatedTokenAccountProgram.CreateAssociatedTokenAccount(
ownerAccount, // Sender Account [Wallet Owner] ?
UsdtAddress, // Tether Address On-Chain ?
ToAddress)). // The Recipient Wallet Address ?
AddInstruction(TokenProgram.Transfer(
ownerAccount,
ToAddress,
100,
ownerAccount)).
Build(new List<Account> { ownerAccount });
var txReq = await rpcClient.SendTransactionAsync(Transaction);
Run Code Online (Sandbox Code Playgroud)
我很抱歉让您等了这么久,但经过多次尝试,都没有成功,我真的认为我需要有人解释一下发送令牌的工作原理。
大家好,希望有一些新的、正在成长的 Motoko IC 区块链开发者。
很小的事情,正如标题所描述的那样。我已经从 DFINITY 安装了 Motoko for VS Code,一切都很棒,包括突出显示(他们说基于 Rust)。我似乎无法显示语法错误波浪线。
我已经联系了 Motoko 官方论坛并尝试了不和谐,但还没有解决方案...
任何建议表示赞赏!
正如我在标题中所悲伤的那样,为什么 IBFT 不被用作公共区块链中的共识协议?毕竟,它是拜占庭容错的,并且可以防止分叉,这比比特币中的工作量证明更重要......
根据 ciphertrace 人员的说法,他们能够使用以下地址了解 BTC 交易的来源和目的地:交易所(Binance、Coinbase 等)、Darkenet 市场、赌博、钱包(Wasabi、Ledger 等)。
他们怎么能这样做呢?这是否意味着当我在 Binance/Wasabi/Ledger 钱包上生成新的 BTC 地址时,该地址不是完全随机的,而是属于预先归属于 Binance/Ledger/Wasabi 等的标记地址池?
如果是的话,这太可怕了!如果不是,他们如何知道这些信息?
资料来源:“昨天,7 月 16 日,太平洋标准时间晚上 8:39,Wasabi 钱包中存入了 2.89 比特币(约占诈骗资金的 22.5%)”,ciphertrace.com
我正在尝试运行这段代码,以使用 ethers.js 库在 JS 中部署智能合约:
const ethers = require("ethers");
const fs = require("fs-extra");
require("dotenv").config();
async function main() {
const provider = new ethers.ethers.JsonRpcProvider(process.env.RPC_URL);
// reads the json private key from file
const encryptedJson = fs.readFileSync("./.encryptedKey.json", "utf-8");
// ========= START FAILING PART ============
let wallet = new ethers.Wallet.fromEncryptedJsonSync(
encryptedJson,
process.env.PRIVATE_KEY_PASSWORD
);
// ========= END FAILING PART ============
wallet = await wallet.connect(provider);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf-8"
);
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, …Run Code Online (Sandbox Code Playgroud)我有网络应用程序,企业应用程序的背景.有了这样的背景; 我在哪里适合区块链!什么是最简单的术语!