https://docs.decentraland.org/creator/development-guide/sdk7/scene-blockchain-operations/
>>
Scene blockchain operations
A Decentraland scene can interface with the Ethereum blockchain.
This can serve to obtain data about the user’s wallet and the tokens in it,
or to trigger transactions that could involve any Ethereum token, fungible or non-fungible.
이건 can 근무할수있다. to 취득하기위해 데이터를 about the 유저의 지갑을 and the토큰들을 in it,
or to 트리거하기위해 거래들을 that could 연루시킬수있을지모를 any ETH토큰,
This can be used in many ways, for example to sell tokens,
to reward tokens as part of a game-mechanic, to change how a player interacts with a scene
if they own certain tokens, etc.
이건 can be used in 다양한 방법들로, for example to sell tokens,
to리워드하기위해 토큰들을 as part of a 게임역학의 일환으로
to change하기위해 how a player가 상호작용하는지 with a 씬들과
if they 소유한다면 어떤 토큰들을, etc.
You use the Ethers.js library in Decentraland scenes, this is a popular 3rd party library to interact with the Ethereum blockchain.
Note that all transactions in the Ethereum mainnet that are triggered by a scene
will require a player to approve and pay a gas fee.
넌 사용한다. the Etjers.js 라이브러리를 in 디센트럴랜드 씬에서, 이건 유명한 3rd 파티 라이브러리다 to 상호작용하기위한 with the ETH 블록체인과
Note that 모든 transactions in the ETH 메인넷에서 that are 트리거되는 by a 씬에의해
will require a 플레이어 to 승인 & 지불하기위해 a 가스비를.
All blockchain operations also need to be carried out as asynchronous functions , since the timing depends on external events.
When running a preview of a scene that uses one of the ethereum libraries,
you must open the preview in a separate browser window,
have Metamask open in your browser, and manually include the string &ENABLE_WEB3.
모든 블록체인 오퍼레이션들은 also need to be 캐리아웃된다. as 비동기function으로써,
since the 타이밍은 의존하므로. on 외부이벤트에의해
(★외부이벤트에 의해 캐리아웃 되므로 비동기가 된다.)
When 동작시킬때 a 미리보기씬 that 사용하는 on of the ETH 라이브러리들을,
넌 must 열어야한다. the 미리보기를 in a 개별 브라우저 윈도우에서,
시켜야만한다. Metamask를 열게끔 in your browser에서, and 수동으로 포함시켜야한다. the string &ENABLE_WEB3를.
If using the CLI, run the preview with:
npm run start --web3
>>
Get player's ethereum account
To get a player's Ethereum account, use the getUserData() function.
import { getUserData } from "~system/UserIdentity"
executeTask(async () => {
let userData = await getUserData({})
if(userData.data.hasConnectedWeb3){
console.log(userData.data.publicKey)
} else {
log("Player is not connected with Web3")
}
})
Note that if a player has entered Decentraland as a guest, they will not have a connected ethereum wallet.
Note that 만약 a 플레이어가 입장했다면 디센트럴랜드에 as a 게스트로써, 그들은 will not 갖고있지않을것이다. a 연결될 ETH 지갑을.
If they are connected as guests, the hasConnectedWeb3
field in the response from getUserData
will be false. If hasConnectedWeb3
is true, then you can obtain the player’s address from the field publicKey
. Learn more about the data you can obtain from a player in get player data
You should wrap the function in an async()
function, learn more about this in async functions
댓글 없음:
댓글 쓰기