将程序部署到本地主机上的 solana 时出现问题

Problem with deploying program to solana on localhost

我正在尝试将一些程序部署到我的本地 solana,但我卡在了这个

    -vote-tutorial
> babel-node src/client/deploy_simplest.js

Deploying...
(node:11063) Warning: N-API is an experimental feature and could change at any time.
Our account: Bfoj2PiwU4qvgHbdiQ7AysM4jKVQD73NF9GdwqMs7yzw
Connection to cluster established: http://localhost:8899 { 'feature-set': 2068214666, 'solana-core': '1.3.15' }
-----
Estimated cost to program load: 407338560  lamports ( 0.40733856 ) Sol
ProgramAccount: Axx1mNZpXBSuHqRYv6Bt6r5H5aKMALH8SuWEs9VNJawJ
Error: failed to get recent blockhash: Error: failed to get recent blockhash: Invalid params: unknown variant `finalized`, expected one of `max`, `recent`, `root`, `single`, `singleGossip`.
    at Connection.getRecentBlockhash (/home/radoslaw/applications/blockchain/simple-vote-tutorial/node_modules/@solana/web3.js/src/connection.js:2363:13)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

我要学习这个教程 https://smith-mcf.medium.com/a-simple-solana-dapp-tutorial-6dedbdf65444

当我使用. start_docker

. start_docker

Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval $(docker-machine env default)

> simplevotetutorial@0.0.1 localnet:up /home/radoslaw/applications/blockchain/simple-vote-tutorial
> set -x; solana-localnet down; set -e; solana-localnet up

+ solana-localnet down
Docker version 20.10.7, build f0df350
++ docker ps --filter 'name=^/solana-localnet$' -q
+ [[ -n '' ]]
+ set -e
+ solana-localnet up
Docker version 20.10.7, build f0df350
+ RUST_LOG=solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=info,solana_bpf_loader=debug,solana_bpf_loader_program=info,solana_rbpf=trace
+ ARGS=(--detach --name solana-localnet --rm --publish 8001:8001/tcp --publish 8899:8899/tcp --publish 8900:8900/tcp --publish 8901:8901/tcp --publish 8902:8902/tcp --publish 9900:9900/tcp --publish 8000:8000/udp --publish 8001:8001/udp --publish 8002:8002/udp --publish 8003:8003/udp --publish 8004:8004/udp --publish 8005:8005/udp --publish 8006:8006/udp --publish 8007:8007/udp --publish 8008:8008/udp --tty --ulimit "nofile=700000" --env "RUST_LOG=$RUST_LOG")
+ [[ -n '' ]]
+ docker run --detach --name solana-localnet --rm --publish 8001:8001/tcp --publish 8899:8899/tcp --publish 8900:8900/tcp --publish 8901:8901/tcp --publish 8902:8902/tcp --publish 9900:9900/tcp --publish 8000:8000/udp --publish 8001:8001/udp --publish 8002:8002/udp --publish 8003:8003/udp --publish 8004:8004/udp --publish 8005:8005/udp --publish 8006:8006/udp --publish 8007:8007/udp --publish 8008:8008/udp --tty --ulimit nofile=700000 --env RUST_LOG=solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=info,solana_bpf_loader=debug,solana_bpf_loader_program=info,solana_rbpf=trace solanalabs/solana:v1.3.15
b3e960613b640aedba3b35d18be03a4e327bab9296bd4e1dba59c0802bd1aecf
+ for _ in 1 2 3 4 5
+ curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1, "method":"getTransactionCount"}' http://localhost:8899
curl: (52) Empty reply from server
+ sleep 1
+ for _ in 1 2 3 4 5
+ curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1, "method":"getTransactionCount"}' http://localhost:8899
{"jsonrpc":"2.0","result":0,"id":1}
+ break

当我 运行 localhost:8899 在 chrome 中出现响应“不允许使用 HTTP 方法。POST 或需要选项”

关于 docker 我需要说我完全是新手,但教程需要它。

很遗憾,您似乎混合使用了新旧版本。您看到的错误:

Error: failed to get recent blockhash: Invalid params: unknown variant `finalized`, expected one of `max`, `recent`, `root`, `single`, `singleGossip`.

是因为你用的是较新版本的@solana/web3.js,网络版本很旧。最简单的解决方案是降级到@solana/web3.js 版本 0.78.2 以继续遵循教程。

另外,还有很多更新的本地开发工具。如果您使用的是新版本的网络和 SDK,则有一个名为 solana-test-validator (https://docs.solana.com/developing/test-validator) 的二进制文件,它比针对 Docker.

进行开发要容易得多